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 | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | lib/fastlane/plugin/firebase_test_lab_android/helper/github_notifier.rb | Ruby | mit | 48 | master | 3,622 | require 'fastlane_core/ui/ui'
require 'json'
require 'net/http'
require 'uri'
module Fastlane
module GitHubNotifier
def self.fold_comments(github_owner, github_repository, github_pr_number, comment_prefix, summary, github_api_token)
res = get_comments(github_owner, github_repository, github_pr_number, gith... |
github | cats-oss/fastlane-plugin-firebase_test_lab_android | https://github.com/cats-oss/fastlane-plugin-firebase_test_lab_android | spec/spec_helper.rb | Ruby | mit | 48 | master | 469 | $LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))
require 'simplecov'
# SimpleCov.minimum_coverage 95
SimpleCov.start
# This module is only used to check the environment is currently a testing env
module SpecHelper
end
require 'fastlane' # to import the Action super class
require 'fastlane/plugin/firebase... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | Gemfile | Ruby | mit | 48 | master | 430 | source 'https://rubygems.org'
gem 'boson'
gem 'boson-more'
gem 'alias'
gem 'bond'
gem 'hirb'
gem 'menu'
gem 'method_lister'
gem 'lightning'
# Commandline tools
#gem 'wolf'
#gem 'vimdb'
#gem 'urls'
#gem 'tag'
#gem 'wolfram'
gem 'ripl'
gem 'ripl-ripper'
gem 'ripl-color_error'
gem 'ripl-commands'
gem 'ripl-after_rc'
gem... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | irbrc.rb | Ruby | mit | 48 | master | 350 | # This irbrc uses my irb manager, boson, to load libraries of irb commands + snippets
require 'rubygems' unless ENV['NO_RUBYGEMS']
begin
# TODO: Remove when boson fixes File.exists?
require 'file_exists'
require 'boson/console'
Boson.start
rescue LoadError
puts "Skipping boson. Likely due to being... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | install.rb | Ruby | mit | 48 | master | 272 | #!/usr/bin/env ruby
require 'fileutils'
home = File.expand_path('~')
FileUtils.ln_s(File.join(Dir.pwd,'irbrc.rb'), File.join(home,'.irbrc'), :verbose=>true, :force=>true)
FileUtils.ln_s(File.join(Dir.pwd,'boson'), File.join(home,'.boson'), :verbose=>true, :force=>true) |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/eval_debugger.rb | Ruby | mit | 48 | master | 458 | # Require this file to see the methods Active Record generates as they are added.
# came from active_record's dev-utils/
class Module #:nodoc:
alias :old_module_eval :module_eval
def module_eval(*args, &block)
if args[0]
puts "----"
print "module_eval in #{self.name}"
print ": file #{args[1]}... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/autoreload.rb | Ruby | mit | 48 | master | 756 | #from http://fukamachi.org/wp/2008/12/31/dead-simple-reload-for-ruby/
module AutoReload
@@required_mod_times = {}
def reload!
diffs = AutoReload.differences # we can only call it once per reload, obviously
if diffs.size > 0
diffs.each {|f| Kernel.load(f)}
puts "reloaded #{diffs.size} file(s)... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/io.rb | Ruby | mit | 48 | master | 3,186 | #hack: shell_support should be in g/ not shellable/?
require 'g/shell_support'
#require shell_support #alias_update, ask_yes_no
require 'g/array'
def smart_system(*args)
options = (args[-1].is_a?(Hash)) ? args.pop : {}
options = {:screen=>false, :print=>false, :return=>nil, :pretend=>false}.alias_update(options)
co... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/double_inclusion.rb | Ruby | mit | 48 | master | 440 | # from http://www.ruby-forum.com/topic/112897#263113
class Module
alias :old_include :include
def include other
old_include other
if self.class == Module
this = self
ObjectSpace.each_object Module do |mod|
p [mod, this, self] if mod < self
this.append_features(mod).module_eval do... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/debug.rb | Ruby | mit | 48 | master | 677 | def pz(*args)
sub = parse_caller(caller[0])[0][2] || "'nil'"
print sub + ": "
p *args
end
def parse_caller(*caller_elements)
caller_elements.map {|e|
file,line, sub = e.split(":")
sub =~ /in `(\w+)'/
sub = $1
[file,line,sub]
}
end
def debug_require(&block)
debug_method('require',&block)
end... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/override_print.rb | Ruby | mit | 48 | master | 511 | def page_stdout(&block)
print_methods = %w{puts printf sprintf p print}
print_methods.each {|e| override_print_method(e)}
yield
print_methods.each {|e| restore_print_method(e)}
end
def override_print_method(method)
eval %[
module ::Kernel
alias :_#{method}_ :#{method}
def #{method}(*args)
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/pstore_access.rb | Ruby | mit | 48 | master | 1,990 | # from http://d.hatena.ne.jp/authorNari/20070729#1185682996
require 'pstore'
class PstoreAccess
def initialize(cols, file_name=(File.dirname(__FILE__) + "/pstore_test"))
@@pstore = PStore.new(file_name)
@@pstore.transaction do
unless @@pstore["root"]
@@pstore["root"] ||= {}
@@pstore["m... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/benchmark_via_callbacks.rb | Ruby | mit | 48 | master | 333 | #from README of irb_callbacks gem
require 'irb_callbacks'
require 'benchmark'
# This little snippet will time each command run via the console.
module IRB
def self.around_eval(&block)
@timing = Benchmark.realtime do
block.call
end
end
def self.after_output
puts "=> #{'%.3f' % @timing} seconds... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/write_files.rb | Ruby | mit | 48 | master | 1,011 | #from http://dotfiles.org/~brendano/.irbrc
def loadmar(filename) open(filename) { |f| Marshal.load f} end
def savemar(o, filename)
open(filename,'w') { |f| Marshal.dump o, f}
filename
end
# yaml and marshal i/o
def loadyaml(filename) YAML.load_file(filename) end
def saveyaml(o, filename)
open(filename... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/progress.rb | Ruby | mit | 48 | master | 1,365 | module Progress
#from http://dotfiles.org/~brendano/.irbrc
def prog(method, interval=100)
count = 0
ret = send(method) { |x|
print "." if (count+=1) % interval == 0
yield x
}
puts
ret
end
# http://snippets.dzone.com/posts/show/3760
def prog2
# move cursor to beginning of l... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/ri.rb | Ruby | mit | 48 | master | 2,440 | #from http://eigenclass.org/hiki/irb+ri+completion
Class Object
def puts_ri_documentation_for(obj, meth)
case self
when Module
candidates = ancestors.map{|klass| "#{klass}::#{meth}"}
candidates.concat(class << self; ancestors end.map{|k| "#{k}##{meth}"})
else
candidates = self.class.ance... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/loop_execute.rb | Ruby | mit | 48 | master | 489 | #from http://po-ru.com/diary/iterative-development-in-irb/
def loop_execute(file)
old_mtime = nil
loop do
# print("\e[sWaiting...")
sleep(0.2) while (mtime = File.stat(file).mtime) == old_mtime
# print("\e[u\e[K")
begin
r = eval(File.read(file))
puts("=> #{r.inspect}")
rescue IRB::Ab... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/gemspec_builder.rb | Ruby | mit | 48 | master | 2,246 | # GemspecBuilder builds a Gem::Specification object by looking up a gem's config in the config file ~/.gems.yml.
# GemspecBuilder assumes the current directory's basename is the gem name (unless told otherwise) and needs to be
# run inside the gem's root directory in order for the gemspec to build correctly.
#
# The bu... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/trace3.rb | Ruby | mit | 48 | master | 2,993 | #!/usr/bin/ruby
CONF = {'ALL'=>true,'SUB'=>true,'INCLUDE_MODULES'=>0,
'FILTER'=>{'event'=>1,'class'=>1,'file'=>0,'level'=>0},
'PRINT_ALL'=>{'event'=>0,'class'=>0,'file'=>1,'line'=>1,'id'=>0,'binding'=>0}
}
#CONF = {%w{EVENT_FILTER 1 PRINT_ALL 0 ONLY_SUB 1}}
$indent = 0;
$level = 0;
$modules = %w{Kernel Module IO F... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/trace2.rb | Ruby | mit | 48 | master | 1,519 | # from http://github.com/xaviershay/dotfiles/blob/master/irbrc
# where_is_this_defined { some_object.some_method() } => <file>:<line>:
def where_is_this_defined(settings={}, &block)
settings[:debug] ||= false
settings[:educated_guess] ||= false
events = []
set_trace_func lambda { |event, file, line, id, b... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/shell_delegator.rb | Ruby | mit | 48 | master | 1,652 | #from http://bangmyhead.com/2008/5/4/interactive-ruby-console-configuration-file-irbc
# and http://woss.name/2006/07/12/using-the-shell-within-irb/
require 'shell'
# Override the command processor widget for inserting system commands so
# that it behaves more like path-processing: earlier commands take precedence.
re... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/dbpedia.rb | Ruby | mit | 48 | master | 978 | # Unfinished attempt at querying dbpedia
module Dbpedia
# @options :resource=>'Honda_Legend', :property=>'engine', :browser=>:boolean,
# :property_type=>{:values=>%w{property ontology}, :default=>'property'}
# Value for a given dbpedia resource's property
def dbpedia_object(options={})
sparql = %[
P... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/rcov.rb | Ruby | mit | 48 | master | 1,090 | require 'thor/tasks'
class Test < Thor
desc "rcov", "rcov"
def rcov
default_options = {:verbose=>true, :rcov=>"-T -x '/Library/Ruby/*'" }
file_list = Dir['test/**/*_test.rb']
create_rcov_cmd(file_list, default_options)
end
def create_rcov_cmd(file_list, opts = {})
#name = opts.delete(:name) ||... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/benchmark.rb | Ruby | mit | 48 | master | 1,320 | # Awesome benchmarking function
# Source: http://ozmm.org/posts/time_in_irb.html
def time(times=1)
require "benchmark"
ret = nil
Benchmark.bm { |x| x.report { times.times { ret = yield } } }
ret
end
# next two from http://pastie.org/private/lx4szvl91miofmyjl46va
def bench(n=100, runs=10, &b)
n = n.to_i
t =... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/progress2.rb | Ruby | mit | 48 | master | 1,556 | #move cursor to beginning of line
cr = "\r"
# ANSI escape code to clear line from cursor to end of line
# "\e" is an alternative to "\033"
# cf. http://en.wikipedia.org/wiki/ANSI_escape_code
clear = "\e[0K"
# reset lines
reset = cr + clear
#-------------------------------- Example 1 -----------------------------... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/pager.rb | Ruby | mit | 48 | master | 385 | #from http://www.ruby-forum.com/topic/84414#155157
# Copious output helper
def less
spool_output('less')
end
def most
spool_output('most')
end
def spool_output(spool_cmd)
require 'stringio'
$stdout, sout = StringIO.new, $stdout
yield
$stdout, str_io = sout, $stdout
IO.popen(spool_cmd, 'w') do |f|
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/rdoc_file_parser.rb | Ruby | mit | 48 | master | 2,260 | #Works with rdoc distributed with ruby 1.8.2
require 'rdoc/rdoc.rb'
## modified rdoc/code_objects.rb
## to index all subs + klasses regardless of nodoc/stopdoc directives
module RDoc
class CodeObject
def stop_doc
@document_self = true
@document_children = true
end
end
class RubyParser
al... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/helper.rb | Ruby | mit | 48 | master | 764 | #from http://github.com/defunkt/barefootexamples/blob/a4e0158e0bb0bc39121841c787d15bbcfe0a0e27/10railsrc.rb
#explained http://errtheblog.com/posts/41-real-console-helpers
def Object.method_added(method)
return super unless method == :helper
(class<<self;self;end).send(:remove_method, :method_added)
def helper(*... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/numeric_enumerable.rb | Ruby | mit | 48 | master | 1,267 | # from nairda-ruby-util gem
module Enumerable
# Calculates sum of the collection.
def sum
inject(nil) { |sum, x| sum ? sum + x : x }
end
# Calculates inversed sum of the collection.
def inversed_sum
1.0 / sum
end
# Calculates reverse sum of the collection.
def reverse_sum
sum.to_i > 0 ? in... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/trace.rb | Ruby | mit | 48 | master | 626 | #from http://blog.bleything.net/2006/12/11/tracing-method-execution
def enable_trace( event_regex = /^(call|return)/, class_regex = /IRB|Wirble|RubyLex|RubyToken/ )
puts "Enabling method tracing with event regex #{event_regex.inspect} and class exclusion regex #{class_regex.inspect}"
set_trace_func Proc.new{|event... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/rshell/aliases.rb | Ruby | mit | 48 | master | 2,341 | class SysAdmin
class <<self
def unalias_dir(dir)
#dirs which should be bunched into a string ie rsync all at once
dirs_to_flatten = [:core]
aliased = fetch_alias(dir) || dir
return nil unless aliased.respond_to?(:map)
unaliased = aliased.map {|e|
(e.is_a?(Symbol)) ? unalias_dir(e) : e
}.flatte... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/rshell/rdoc.rb | Ruby | mit | 48 | master | 2,297 | require "g/hash"
require "g/dir"
GEMDIR = '/opt/local/lib/ruby/gems/1.8/gems'
GEMDOCDIR = '/opt/local/lib/ruby/gems/1.8/doc'
#RIDIR= '/usr/local/share/ri/1.8/'
RIDIR= '/opt/local/share/ri/'
RAILS_GEMS = %w{activesupport activerecord actionmailer actionpack rails actionwebservice}
class RIManager
class <<self
def ge... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/todo/rshell/rsync.rb | Ruby | mit | 48 | master | 2,771 | require 'commands/irb/aliases'
class SysAdmin
class <<self
#Rsync
def smart_rsync(*args)
#should have matching entries in dir_aliases
if args[0].is_a?(Symbol) && new_source = unalias_dir(args[0])
if new_dest = fetch_dest_alias(args[0])
new_args = [new_source, new_dest]
new_args += args[1..-1... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/dbm.rb | Ruby | mit | 48 | master | 297 | module Dbm
def self.config; {:namespace=>true}; end
def self.included(mod)
require 'dbm'
end
def write(hash, file='blah.dbm')
DBM.open(file) do |e|
hash.each do |k,v|
e[k] = v
end
end
end
def read(file='blah.dbm')
DBM.open(file).to_hash
end
end |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/boson.rb | Ruby | mit | 48 | master | 3,935 | module BosonLib
# @render_options :change_fields=>['name', 'commands']
# @options :type=>:boolean, [:skip_booleans, :S]=>true, :global_options=>:boolean, :use_parser=>:boolean
# @desc Lists option stats from all known commands. Doesn't include boolean options
# if listing option names.
def opts(options={})
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/misc.rb | Ruby | mit | 48 | master | 1,899 | module Misc
# Hash of class dependencies excluding error-related ones
def dependencies
deps = {}
ObjectSpace.each_object Class do |mod|
next if mod.name =~ /Errno/
next if mod < Exception
deps[mod.to_s] = mod.superclass.to_s
end
# dependencies.inject({}) {|h,(k,v)| (h[v] ||= []) <<... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/watch.rb | Ruby | mit | 48 | master | 1,160 | # Inspired loosely by http://gist.github.com/113226
module Watch
# @options :period=>1, :debug=>:boolean, :command=>:string, :system=>:string
# @desc Watches paths periodically with :period and executes commands and/or
# reports paths that have changed
def watch(*globs)
options = globs[-1].is_a?(Hash) ? glo... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/gem_brain.rb | Ruby | mit | 48 | master | 4,294 | module GemBrain
def self.included(mod)
require 'yaml'
require 'rubygems'
end
def self.config
{:dependencies=>['exp/gem_actions']}
end
# @render_options :sort=>{:enum=>false, :values=>%w{to_s}}
# @options :type=>{:type=>:string, :default=>:unapproved, :values=>[:github, :query, :approved, :unap... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/ext_loader.rb | Ruby | mit | 48 | master | 895 | module ExtLoader
# Loads an extension library i.e. libraries under core/*.
def load_extension(lib_path)
return "Extension not found" unless (lib = Boson.library(lib_path))
basename = File.basename(lib_path)
eval %[module Boson::Commands::NewCore ; end]
new_mod = Boson::Util.camelize "boson/commands/... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/ansi.rb | Ruby | mit | 48 | master | 856 | module Ansi
def self.included(mod)
require 'ansi' # rip install http://github.com/ssoroka/ansi.git
end
COLORS = [:magenta, :green, :white, :blue, :cyan, :yellow, :black, :purple, :light_blue, :red]
# @options :background_color=>{:type=>:string, :values=>COLORS}, :color=>{:type=>:string, :values=>COLORS}
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/rails_overview.rb | Ruby | mit | 48 | master | 3,105 | # Doesn't currently work because it's loading an incorrect version of rdoc
module Overview
# This was useful back in the day when Rails projects were small and I wanted to a quick overview of
# the project. Can be run from the root directory of a rails project or with a specified rails directory.
# By default thi... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/dir.rb | Ruby | mit | 48 | master | 1,975 | # All methods here take an optional directory argument, defaulting to the current directory.
module DirLib
# Returns current directory with a '/' appended.
def mpwd
Dir.pwd + "/"
end
# Returns entries from simple_entries() that are directories.
def dir_children(dirname=mpwd)
simple_entries(dirname).f... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/path_finder.rb | Ruby | mit | 48 | master | 833 | module PathFinder
# option :gemdir, "Include paths to gem directories as defined by your gem binary"
# option :dir, "Return directories of files"
# @options :verbose=>:boolean, :gemdir=>:boolean, :dir=>:boolean
# Looks in standard ruby's library paths for a given file's basename.
def path_finder(basename, opt... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/midi.rb | Ruby | mit | 48 | master | 576 | # from http://github.com/aquabu/irbivore
module Midi
def self.included(mod)
require 'midiator'
end
# @config :default_option=>'note'
# @options :note=>{:type=>:numeric, :required=>true},:duration=>0.1, :channel=>0, :velocity=>100
# Play midi note
def note(options={})
Midi.client.play *options.value... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/stats.rb | Ruby | mit | 48 | master | 1,683 | module Stats
# Calculates total for all numeric keys in an array of hashes
def totals(enumerable)
Stats.calculate(enumerable, :total)
end
# Calculates average for all numeric keys in an array of hashes
def average(enumerable)
Stats.calculate(enumerable, :average)
end
# Calculates standard deviat... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/grit.rb | Ruby | mit | 48 | master | 3,460 | module Git
def self.included(mod)
require 'grit'
end
# @render_options :change_fields=>['repo', 'pending'], :sort=>'pending',
# :reverse_sort=>true
# @option :push, :type=>:boolean, :desc=>"Push repos with pending commits"
# @option :repo, :type=>:string, :values=>%w{all gems menu}, :enum=>false, :des... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/do.rb | Ruby | mit | 48 | master | 1,037 | module Do
def self.append_features(mod)
require 'rdf'
require 'rdf/ntriples'
require 'data_objects'
require 'do_sqlite3'
require 'rdf/do'
super
rescue LoadError
false
end
def do_repo
@do_repo ||= RDF::DataObjects::Repository.new('sqlite3:test.db')
end
# @config :option_comm... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/file.rb | Ruby | mit | 48 | master | 1,032 | module FileLib
# @options :file=>true
def md5_hash(string, options={})
require 'digest/md5'
Digest::MD5.hexdigest(options[:file] ? File.read(string) : string)
end
# @options :file=>true
def sha1_hash(string, options={})
require 'digest/sha1'
Digest::SHA1.hexdigest(options[:file] ? File.read(s... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/url_check.rb | Ruby | mit | 48 | master | 988 | module UrlCheck
def self.included(mod)
require 'net/http'
require 'redirect_follower'
end
# Pings and resolves redirects for given urls. Returns their status code and final url
def url_check(urls, options={})
responses = urls.map {|e| fetch_url(e, options) }
render responses, :fields=>[:url, :c... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/system.rb | Ruby | mit | 48 | master | 1,581 | # Different ways of implementing system()
module System
# @options :error=>:boolean
# Returns stdout or stderr string from shell command
def shell(*args)
require 'open3'
options = args[-1].is_a?(Hash) ? args.pop : {}
stdin, stdout, stderr = Open3.popen3(*args)
options[:error] ? stderr.read : stdou... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/delicious.rb | Ruby | mit | 48 | master | 361 | module Delicious
def self.included(mod)
# maybe consider replacing with concise hand rolled lib:
# http://github.com/citizen428/unsavory/blob/37e0d2c211fa303e1a36adcc87ec66e4f7344312/lib/delicious.rb
require 'www/delicious'
end
def delicious
@delicious ||= ::WWW::Delicious.new(ENV['DELICIOUS_USE... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/readme.rb | Ruby | mit | 48 | master | 1,490 | module Readme
# List readme sections
def sections
Repo.objects.map {|e| [e.name, e.sections] }
end
# @render_options :fields=>[:name, :missing, :extras]
# @options :reveal=>:boolean, :menu=>:boolean
# List differences in readme sections
def section_diff(options={})
common = %w{Description Bugs/I... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/paz.rb | Ruby | mit | 48 | master | 3,777 | # Manage gem-building files across projects
module Paz
def self.config
{:namespace=>'z'}
end
def self.included(mod)
require 'fileutils'
end
# @options :verbose=>:boolean, :noop=>:boolean
# Update current project
def push(dir='.', options={})
FileUtils.cp_r Paz.template_dir+'/.', dir , option... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/gem_grep.rb | Ruby | mit | 48 | master | 1,314 | module Gemgrep
def self.after_included
require 'gem_grep'
require 'rubygems/specification_hack'
end
# @render_options :fields=>{:default=>GemGrep.display_fields, :values=>GemGrep.valid_gemspec_columns.map {|e| e.to_sym}}
# @options :grep_fields=>{:default=>GemGrep.grep_fields, :values=>GemGrep.valid_ge... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/key_master.rb | Ruby | mit | 48 | master | 796 | module KeyMaster
# @render_options :change_fields=>%w{function key}, :sort=>'function'
# Lists keys used
def keys_used
@functions_hash ||= begin
hash = IO.readlines(File.expand_path("~/.key_bindings")).select {|e| e =~ /^[^\n#]/ }.
inject({}) {|h,e| k,v = e.chomp.split(/\s*:\s*/); (h[v] ||= []) ... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/math.rb | Ruby | mit | 48 | master | 481 | module MathLib
# Calculates the +nth+ root of a +x+.
def root(x, n=2)
x ** (1.0 / n)
end
#from http://www.elctech.com/snippets/convert-filesize-bytes-to-readable-string-in-javascript
# Converts bytes to human readable bytes i.e. kb + MB
def human_bytes(bytes)
s = ['bytes', 'kb', 'MB', 'GB', 'TB', '... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/find.rb | Ruby | mit | 48 | master | 476 | module FindLib
def self.included(mod)
# require 'file/find' #gem install file-find
end
# @options :maxdepth=>:numeric, :path=>:array, :return_array=>:boolean, :prune=>:string
# A *nix like find that can return an array of found files
def find(pattern, options={})
return_array = options.delete(:return... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/history.rb | Ruby | mit | 48 | master | 2,076 | # Similar to utility_belt's command history
# Prints, evals and edits history by specifying start and end history numbers.
# For example, 1-3,7 specifies lines 1 through 3 and line 7. Default is all lines.
# consider copy history like http://pastie.org/501623
module History
class<<self; attr_accessor :original_histor... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/histogram.rb | Ruby | mit | 48 | master | 2,604 | module Histogram
def self.included(mod)
require 'aggregate'
end
# irb> stats(100, 0, 10, 1) { sleep(rand / 100) }
# mean: 5.99ms
# min: 1.49ms
# max: 9.28ms
# stddev: 2.54ms
# value |------------------------------------------------------------------| count
# 0 |@@ ... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/pstore.rb | Ruby | mit | 48 | master | 579 | module Pstore
def self.config
{:namespace=>true}
end
def self.included(mod)
require 'pstore'
end
def db_init(yaml=false)
if yaml
require 'yaml'
require 'yaml/store'
@db = YAML::Store.new(File.join(Boson.repo.config_dir, 'main.pstore.yml'))
else
@db = PStore.new(File.j... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/gem_actions.rb | Ruby | mit | 48 | master | 1,523 | module GemActions
# @render_options :fields=>[:name, :summary, :homepage, :authors], :max_fields=>{:default=>{:authors=>0.1}}
# @config :menu=>{:command=>:gem_uninstall}
# @options :limit=>200
def gemspecs(options={})
::Gem.source_index.gems.values.inject({}) {|t,e| t[e.name] ||= e; t }.values[0,options[:li... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/lightning.rb | Ruby | mit | 48 | master | 1,076 | # Commands mainly for use while developing Lightning
module Dev
def self.included(mod)
require 'lightning'
end
# @config :alias=>'lb'
# Build's local version using bin/lightning-build
def dev_build(file=nil)
system("bin/lightning build #{file}")
if file
file_string = File.read(file)
f... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/debug.rb | Ruby | mit | 48 | master | 584 | module ::Boson::Scientist
alias_method :_call_original_command, :call_original_command
# benchmark version
# def call_original_command(args, &block)
# require 'benchmark'
# output = nil
# bench = Benchmark.measure do
# output = _call_original_command(args, &block)
# end
# puts " #{name}... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/option_usage_fields.rb | Ruby | mit | 48 | master | 575 | # Allows passing fields to usage_options i.e. commands -hv -u=f:* # or -u=f:name.alias
class ::Boson::OptionParser
alias_method :old_get_usage_fields, :get_usage_fields
def get_usage_fields(fields)
if fields
default_fields = [:name, :alias, :type]
all_fields = option_attributes.map {|k,v| v.keys }.... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/hash_option.rb | Ruby | mit | 48 | master | 877 | # Tweaks to hash option
class ::Boson::OptionParser
# Allow for aliasing hash :values with a :values attribute
def create_hash(value)
hash = super
if (values = current_attributes[:values])
values = values.sort_by {|e| e.to_s }
hash = hash.inject({}) {|h,(k,v)|
h[k] = auto_alias_value(val... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/current_option_command.rb | Ruby | mit | 48 | master | 600 | # This plugin makes the current command on a commandline an OptionCommand.
# This is useful when wanting to use other plugins that depend on commands having options.
module CurrentOptionCommand
def self.append_features(mod)
super if Boson.const_defined?(:BinRunner)
end
def self.after_included
::Boson::C... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/global_option.rb | Ruby | mit | 48 | master | 553 | class ::Boson::OptionCommand
BASIC_OPTIONS[:global] = {:type=>:string, :desc=>"Pass a string of global options without the dashes"}
alias_method :_parse_global_options, :parse_global_options
def parse_global_options(args)
global_options = _parse_global_options(args)
if global_options[:global]
glob... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/my_pipe_options.rb | Ruby | mit | 48 | master | 1,306 | module MyPipeOptions
def self.after_included
::Boson::OptionCommand::PIPE_OPTIONS[:pipes].merge! :enum=>false, :values=>%w{pastie_string gist_string}
::Boson::Pipe.add_pipes :command=>{
:alias=>'C', :type=>:array, :desc=>"Pipe to commands sequentially", :filter=>true, :pipe=>:post_command},
:key_s... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/translate_bin_args.rb | Ruby | mit | 48 | master | 397 | class ::Boson::BinRunner
class <<self
alias_method :_translate_args, :translate_args
def translate_args(args, piped)
args = _translate_args(args, piped)
if commands.size > 1
if commands.first == @command
Scientist.render = false
# elsif commands.last == @command
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/global_option_defaults.rb | Ruby | mit | 48 | master | 355 | class ::Boson::OptionCommand
alias_method :_set_global_option_defaults, :set_global_option_defaults
def set_global_option_defaults(opts)
opts = _set_global_option_defaults(opts)
if opts[:fields][:values]
opts[:filters][:keys] ||= opts[:fields][:values]
opts[:max_fields][:keys] ||= opts[:fields][... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/plugins/object_namespace.rb | Ruby | mit | 48 | master | 865 | # Plugin that delegates namespace calls to an object defined by a method whose name is the same
# as its library.
class ::Boson::Namespace
class<<self
alias_method :_create, :create
def create(name, library)
if library.object_namespace && library.module.instance_methods.map {|e| e.to_s}.include?(name)
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/db/mongoid.rb | Ruby | mit | 48 | master | 294 | __END__
require 'mongoid'
Mongoid.configure {|c| c.master = Mongo::Connection.new.db('sample') }
class ::Url
include Mongoid::Document
field :name
field :desc
has_many_related :tags
end
class ::Tag
include Mongoid::Document
field :name
field :desc
belongs_to_related :url
end |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/db/couchdb.rb | Ruby | mit | 48 | master | 564 | __END__
require 'couch_potato'
CouchPotato::Config.database_name = 'urls'
class Url
include CouchPotato::Persistence
property :name
view :all, :key=>:name
end
u1 = Url.new :name=>'aaa.com'
CouchPotato.database.save_document u1
require 'couch_foo'
CouchFoo::Base.set_database(:host => "http://localhost:5984", :da... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/db/mongo_mapper.rb | Ruby | mit | 48 | master | 632 | __END__
require 'mongo_mapper'
MongoMapper.connection = Mongo::Connection.new
MongoMapper.database = 'mm-sample'
# require 'taggable'
class ::Url
include MongoMapper::Document
# include Taggable
many :tags, :as=>:taggable
key :name, String, :required => true
timestamps!
end
class ::Tag
include MongoMappe... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/db/datamapper.rb | Ruby | mit | 48 | master | 357 | __END__
require 'dm-core'
::DataMapper.setup(:default, 'sqlite3::memory:')
class Url
include DataMapper::Resource
property :id, Serial
property :name, String
property :desc, String
has n, :tags
end
class Tag
include DataMapper::Resource
property :id, Serial
property :name, String
belongs_to :url
end... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/exp/db/misc.rb | Ruby | mit | 48 | master | 315 | __END__
require 'ripple'
class Url
include Ripple::Document
property :name, String
end
require 'friendly'
Friendly.configure :adapter => "mysql", :host => "localhost", :user => "root", :password => "",:database => "test"
class Url
include Friendly::Document
attribute :name, String
indexes :name
end |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/array.rb | Ruby | mit | 48 | master | 3,601 | module ArrayLib
# @desc Allows you to specify ranges of elements and individual elements with one string,
# array starts at 1. Example: choose first and fourth through eighth elements: '1,4-8'
def multislice(arr, input, options={})
options = {:splitter=>","}.merge(options)
return arr if input.strip == '*'... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/object.rb | Ruby | mit | 48 | master | 1,349 | module ObjectLib
# Returns eigenclass/metaclass/singleton-class of given object
def metaclass(obj)
class << obj; self; end
end
# List methods which aren't in superclass
def local_methods(obj)
(obj.methods - obj.class.superclass.instance_methods).sort
end
# Inspects the object or yields. Useful i... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/string.rb | Ruby | mit | 48 | master | 442 | module StringLib
# @desc Counts # of times the given string is in the string. This is unlike String.count which
# only counts the given characters.
def count_any(string)
count = 0
self.gsub(string) {|s|
count += 1
string
}
count
end
# Pipes stringing to command
def pipe(string,... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/regexp.rb | Ruby | mit | 48 | master | 221 | module RegexpLib
# From pickaxe. Shows regexp in a string by quoting it with << >>.
def show_regexp(regex, string)
if string =~ regex
"#{$`}<<#{$&}>>#{$'}"
else
"no match"
end
end
end |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/struct.rb | Ruby | mit | 48 | master | 520 | module StructLib
# Creates an object from a Struct-defined class given a hash of attributes
def open_struct(hash)
Struct.new(*hash.keys.sort).new(*hash.values_at(*hash.keys.sort))
end
# from http://blog.rubybestpractices.com/posts/rklemme/017-Struct.html
# Makes a Struct class comparable
def self.compa... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/module.rb | Ruby | mit | 48 | master | 491 | module ModuleLib
# Children modules immediately under a module.
def nested_children(mod)
real_constants(mod).map {|e| mod.const_get(e) }.select {|e| e.is_a?(Module) } - [mod]
end
# Last part of a module name i.e. Boson::Commands::Ansi -> Ansi
def nested_name(mod)
mod.to_s.split("::")[-1]
end
# R... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/class.rb | Ruby | mit | 48 | master | 875 | module ClassLib
# Returns ancestors that aren't included modules and the class itself.
def real_ancestors(klass)
ancestors - included_modules - [klass]
end
#Returns all objects of class.
def objects(klass)
object = []
ObjectSpace.each_object(klass) {|e| object.push(e) }
object
end
# Retu... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/hash.rb | Ruby | mit | 48 | master | 2,638 | module HashLib
# @desc Returns a hash which will set its values by calling each value with the given method and
# optional argument. If a block is passed, each value will be set the value returned by its block call.
def vmap(hash, arg=nil,method='[]',&block)
new_hash = {}
if block
hash.each {|k,v|
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/core/float.rb | Ruby | mit | 48 | master | 221 | module FloatLib
# Round to a number of decimal places
def round_to(float, place)
#(float * 10 ** place).round.to_f / 10 ** place
# ("%.#{place}f" % float).to_f
sprintf("%.#{place}f", float).to_f
end
end |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/gem_release.rb | Ruby | mit | 48 | master | 3,323 | module GemRelease
def self.config
{:dependencies=>['public/release', 'exp/paz', 'exp/readme', 'personal/system_misc']}
end
# @options :test => true, :sync => true, :bare => false
# Checklist to run before releasing a gem
def pre_release(options={})
raise "Repo not clean" if !`git status -s`.empty?
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/backup.rb | Ruby | mit | 48 | master | 2,415 | module Backup
#s3sync.rb comes from http://s3sync.net
# @options :directory=>:string, :s3sync_options=>:string
# Back up files to s3
def s3(options={})
directories = options[:directory] ? [options[:directory]] : ['~/code','~/docs', '~/backup']
directories.each do |e|
cmd = "s3sync.rb --exclude=~$ ... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/xmms2.rb | Ruby | mit | 48 | master | 766 | module Xmms2
# @render_options :fields=>{:default=>[:track, :title, :time]}
# @config :alias=>'ss', :menu=>{:command=>'play_track', :ask=>false}
# Searches for songs, displays results in menu and lets you jump to chosen song
def search_songs(query, options={})
parse_songs `xmms2 list |grep #{query}`.split("... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/alias.rb | Ruby | mit | 48 | master | 460 | module AliasLib
def self.included(mod)
require 'alias'
end
def self.after_included
::Alias.create :file=>"~/.alias.yml", :verbose=>true
end
# @render_options :sort=>{:values=>[:type, :alias, :class, :name]}
# @options {:type=>:string, :alias=>:string, :class=>:string, :name=>:string}
# Searches ... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/hirb.rb | Ruby | mit | 48 | master | 747 | module HirbLib
# Toggles hirb between being enabled and disabled
def toggle_hirb
Hirb::View.enabled? ? Hirb.disable : Hirb.enable
end
#@render_options :change_fields=>%w{class config}
# Displays view config for each class
def hirb_config
Hirb::View.formatter_config
end
def self.after_included
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/core_gem.rb | Ruby | mit | 48 | master | 950 | module CoreGem
# my ruby extensions: http://github.com/cldwalker/my_core
# use core to load extensions: http://github.com/cldwalker/core
def self.included(mod)
require 'local_gem'
require 'core'
end
def self.disabled
#::Core.default_library = MyCore
libraries = {
:activesupport=>{:base_... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/system_misc.rb | Ruby | mit | 48 | master | 4,506 | module SystemMisc
# Install latest tabtab + copy files + git repo
def tabtab
cmd = "install_tabtab && cp -f ~/.tabtab.bash ~/code/repo/dotfiles/.bash/completion/.tabtab.bash"
system(cmd)
end
# Diffs my latest template gitignore with current dir gitignore
def diff_gitignore
system("diff .gitignore... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/rails.rb | Ruby | mit | 48 | master | 736 | module RailsLib
def self.append_features(mod)
super if ENV['RAILS_ENV'] || defined? Rails
end
def self.after_included
IRB_PROCS[:setup_personal] = method(:setup_personal) if Object.const_defined?(:IRB_PROCS)
end
def self.setup_personal(*args)
require 'console_update'
ConsoleUpdate.enable_nam... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/tree.rb | Ruby | mit | 48 | master | 1,982 | # Prints trees of classes and modules.
module Tree
def self.config
{:dependencies=>['core/class', 'core/module']}
end
OPTIONS = {:class=>:string, :children_method=>:string, :type=>{:type=>:string, :values=>[:directory, :basic, :number]}}
# @options OPTIONS
# Prints an inheritance tree given a root class
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/jekyll/main.rb | Ruby | mit | 48 | master | 3,666 | # Wrote a post about an old thor-version of this library:
# http://tagaholic.me/2009/02/19/meta-templates-for-github-pages.html
module Main
def self.included(mod)
require 'erb'
end
# Creates tag xml pages
def tag_xml_pages(*tags)
options = args[-1].is_a?(Hash) ? args.pop : {}
tags.each {|e|
c... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/commands/personal/gh_pages/main.rb | Ruby | mit | 48 | master | 5,030 | # These tasks create and manage project pages across projects/repositories based on a common project template.
# Since the project template is given a project-specific config, each project page can be customized as needed.
#
# First time setup:
# * git clone git://github.com/cldwalker/irbfiles.git
# * boson install gh_... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/lib/clipboard.rb | Ruby | mit | 48 | master | 1,509 | # original clipboard code: http://project.ioni.st/post/1334#snippet_1334
# turned it into a class to make it flexxy:
# http://gilesbowkett.blogspot.com/2007/09/improved-auto-pastie-irb-code.html
# Extended to handle windows and linux as well
# copied from http://github.com/akitaonrails/utility-belt/blob/bdf51947645a44c... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/lib/counting_prompt.rb | Ruby | mit | 48 | master | 1,955 | # Extracted from anonymous script with original class name CharGrabber
require 'thread'
class CountingPrompt
CLEAR_SCREEN = "\e[2J\e[f"
COLORS = {:red => 1, :yellow => 3, :magenta => 5}
class <<self
def open_stty
begin
system("stty raw -echo")
yield
ensure
system("stty -raw echo")
... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/lib/decoration.rb | Ruby | mit | 48 | master | 619 | # from http://blog.rubybestpractices.com/posts/gregory/008-decorator-delegator-disco.html
require 'delegate'
# with minor tweaks from tjstankus
module Decoration
def decorator_for(*types, &block)
types.each do |type|
decorators[type] = Module.new(&block)
end
end
def decorators
@decorators ||=... |
github | cldwalker/irbfiles | https://github.com/cldwalker/irbfiles | boson/lib/null_object.rb | Ruby | mit | 48 | master | 217 | # from http://github.com/avdi/cowsay/blob/master/lib/cowsay.rb
class NullObject
def method_missing(*args, &block)
self
end
def nil?; true; end
end
def Maybe(value)
value.nil? ? NullObject.new : value
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.