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
tily/ruby-faker-japanese
https://github.com/tily/ruby-faker-japanese
spec/name_spec.rb
Ruby
mit
89
master
1,331
# -*- coding:utf-8 -* require File.expand_path(File.dirname(__FILE__) + '/spec_helper') describe Faker::Japanese::Name do before do @expect = { :first_name => [['良子', 'リョウコ'], ['武', 'タケシ'], ['修三', 'シュウゾウ']], :last_name => [['木村', 'キムラ'], ['田中', 'タナカ'], ['佐藤', 'サトウ']] } @expect.each do |k, v| ...
github
tily/ruby-faker-japanese
https://github.com/tily/ruby-faker-japanese
script/generate.rb
Ruby
mit
89
master
1,813
#!/usr/bin/env ruby require 'erb' DEFAULT_DIC_PATH = '/var/lib/chasen/dic/naist-jdic-utf8/naist-jdic.dic' NAME_CLASS_PATH = File.dirname(__FILE__) + '/../lib/faker/japanese/name.rb' def parse_dic(dic_path) names = Hash.new {|h,k| h[k] = [] } File.open(dic_path).each do |line| if type = line[/\(品詞 \(名詞 固有名詞 人...
github
tily/ruby-faker-japanese
https://github.com/tily/ruby-faker-japanese
example/your_friends.rb
Ruby
mit
89
master
250
# -*- coding:utf-8 -* $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib') require 'rubygems' require 'faker/japanese' 20.times { name = Faker::Japanese::Name.name puts "#{name} (#{name.yomi})" }
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
action_parameter.gemspec
Ruby
mit
89
master
993
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "action_parameter/version" Gem::Specification.new do |s| s.name = "action_parameter" s.version = ActionParameter::VERSION.dup s.platform = Gem::Platform::RUBY s.summary = "Single Responsability Principle fo...
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
Rakefile
Ruby
mit
89
master
632
#!/usr/bin/env rake begin require 'bundler/setup' require 'bundler/gem_tasks' rescue LoadError raise 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'ActionParameter' rdoc.options << '--l...
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
lib/action_parameter.rb
Ruby
mit
89
master
263
require 'action_pack' require 'active_support' require 'action_parameter/railtie' if defined?(Rails) module ActionParameter extend ActiveSupport::Autoload autoload :Base, 'action_parameter/base.rb' autoload :Helpers, 'action_parameter/helpers.rb' end
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
lib/generators/parameters/parameters_generator.rb
Ruby
mit
89
master
294
require 'rails/generators' require 'rails/generators/named_base' class ParametersGenerator < Rails::Generators::NamedBase source_root File.expand_path('../templates', __FILE__) def parameters template "parameter_class.rb", "app/parameters/#{name.underscore}_parameters.rb" end end
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
lib/action_parameter/railtie.rb
Ruby
mit
89
master
254
require 'rails/railtie' module ActionParameter class Railtie < Rails::Railtie initializer "action_parameter.helpers" do |app| ActiveSupport.on_load :action_controller do include ActionParameter::Helpers end end end end
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
lib/action_parameter/base.rb
Ruby
mit
89
master
2,173
module ActionParameter class Base attr_accessor :params # initialize: Initialize parameter class and creates controller_name and action_name helpers. # # == Options # # * <tt>params</tt> - The ActionController::Parameters instance from the controller who initialize this. def initialize(p...
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
lib/action_parameter/helpers.rb
Ruby
mit
89
master
1,670
module ActionParameter module Helpers protected # permitted_params: Returns an ActionParameter instance. # # == Options # # * <tt>options</tt> - Hash with one valid key: class. # * <tt>options[:class]</tt> - Symbol value with the name of the Parameters class you wan...
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
test/test_helper.rb
Ruby
mit
89
master
664
require 'coveralls' Coveralls.wear! require 'bundler' Bundler.setup require 'test/unit' require 'mocha/setup' # Configure Rails ENV["RAILS_ENV"] = "test" require 'active_support' require 'action_controller' require 'action_dispatch/middleware/flash' $:.unshift File.expand_path('../../lib', __FILE__) require 'actio...
github
edelpero/action_parameter
https://github.com/edelpero/action_parameter
test/action_parameter_test.rb
Ruby
mit
89
master
3,083
require 'test_helper' UserParameters = Class.new(ActionParameter::Base) CustomerParameters = Class.new(ActionParameter::Base) Admin = Module.new Admin::UserParameters = Class.new(ActionParameter::Base) Admin::CustomerParameters = Class.new(ActionParameter::Base) module SharedActionMethods def permitted_params_with...
github
krobertson/metis
https://github.com/krobertson/metis
metis.gemspec
Ruby
apache-2.0
89
master
626
$:.unshift(File.dirname(__FILE__) + '/lib') require 'metis/version' Gem::Specification.new do |s| s.name = 'metis' s.version = Metis::VERSION s.platform = Gem::Platform::RUBY s.extra_rdoc_files = ["README.md", "LICENSE" ] s.summary = "A server monitoring framework built to bring flexible and testable monitor...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis.rb
Ruby
apache-2.0
89
master
394
class Metis STATUS_OK = 0 STATUS_WARNING = 1 STATUS_CRITICAL = 2 end require 'metis/version' require 'metis/mixin/from_file' require 'metis/mixin/params_validate' require 'metis/context' require 'metis/check_definition' require 'metis/check_definition_list' require 'metis/provider' require 'metis/nrpe_packet' re...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/check_definition.rb
Ruby
apache-2.0
89
master
775
require 'metis/mixin/params_validate' class Metis class CheckDefinition include Metis::Mixin::ParamsValidate attr_accessor :name, :params def initialize @name = nil @params = {} @requires = [] end def attribute(attr_name, validation_opts={}) shim_method=<<-SHIM de...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/nrpe_packet.rb
Ruby
apache-2.0
89
master
1,610
require 'zlib' class Metis class NrpePacket NRPE_PACKET_VERSION_3 = 3 NRPE_PACKET_VERSION_2 = 2 NRPE_PACKET_VERSION_1 = 1 QUERY_PACKET = 1 RESPONSE_PACKET = 2 MAX_PACKETBUFFER_LENGTH = 1024 MAX_PACKET_SIZE = 12 + 1024 attr_accessor :packet_version, :crc32, :result_code, :buffer ...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/provider.rb
Ruby
apache-2.0
89
master
1,555
class Metis class Provider attr_reader :definition, :response_code, :response_message def initialize(definition, context) @definition = definition @context = context @response_code = Metis::STATUS_OK end def params definition.params end def warn(msg) unless @re...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/configuration.rb
Ruby
apache-2.0
89
master
796
class Metis::Configuration include Metis::Mixin::FromFile include Metis::Mixin::ParamsValidate attr_reader :params, :blocks def initialize @params = {} @blocks = Hash.new { |h,k| h[k] = [] } end def checks_include_directories(*arg) set_or_return( :checks_include_directories, arg.e...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/check_definition_list.rb
Ruby
apache-2.0
89
master
386
require 'metis/mixin/from_file' require 'metis/check_definition' class Metis class CheckDefinitionList include Metis::Mixin::FromFile attr_accessor :defines def initialize @defines = Hash.new end def define(check_name, &block) @defines[check_name] = CheckDefinition.new @defin...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/application.rb
Ruby
apache-2.0
89
master
804
class Metis::Application def initialize(opts={}) @options = opts end def run if @options[:daemonize] daemonize! else start end end def start # write pid file File.open(@options[:pid_file], 'w') { |f| f.write(Process.pid.to_s) } if @options[:pid_file] # load context ...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/server.rb
Ruby
apache-2.0
89
master
1,006
require 'socket' require 'openssl' class Metis::Server DEFAULT_OPTIONS = { :host => '0.0.0.0', :port => 5668, :enable_ssl => true } def initialize(context, options={}) @context = context @options = DEFAULT_OPTIONS.merge...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/context.rb
Ruby
apache-2.0
89
master
1,307
class Metis class Context attr_reader :definitions, :configuration def initialize(configuration_file=nil) @definitions = Hash.new @configuration_file = configuration_file if configuration_file && File.exists?(configuration_file) @configuration = Metis::Configuration.new @configurati...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/client.rb
Ruby
apache-2.0
89
master
1,186
require 'timeout' class Metis::Client def initialize(socket, context) @socket = socket @context = context end def process query = Metis::NrpePacket.read(@socket) # ensure it doesn't specify any commands if query.buffer =~ /!/ send_response(Metis::STATUS_CRITICAL, "Arguments not allow...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/mixin/params_validate.rb
Ruby
apache-2.0
89
master
7,791
class Metis module Mixin module ParamsValidate # Takes a hash of options, along with a map to validate them. Returns the original # options hash, plus any changes that might have been made (through things like setting # default values in the validation map) # # For example: #...
github
krobertson/metis
https://github.com/krobertson/metis
lib/metis/mixin/from_file.rb
Ruby
apache-2.0
89
master
956
class Metis module Mixin module FromFile # Loads a given ruby file, and runs instance_eval against it in the context of the current # object. # # Raises an IOError if the file cannot be found, or is not readable. def from_file(filename) if File.exists?(filename) && File.read...
github
krobertson/metis
https://github.com/krobertson/metis
spec/client_spec.rb
Ruby
apache-2.0
89
master
1,756
require 'spec_helper' describe Metis::Client do before do @socket = mock @context = Metis::Context.new File.dirname(__FILE__)+"/resources/sample/metis.rb" @context.load @client = Metis::Client.new @socket, @context end describe '.process' do it 'should process a valid packet, run the command...
github
krobertson/metis
https://github.com/krobertson/metis
spec/spec_helper.rb
Ruby
apache-2.0
89
master
226
require "simplecov" SimpleCov.start do add_filter "spec" end # Add the root to the load path. $LOAD_PATH << File.join(File.dirname(__FILE__), "..", "lib") require "bundler" Bundler.require require "rspec" require "metis"
github
krobertson/metis
https://github.com/krobertson/metis
spec/provider_spec.rb
Ruby
apache-2.0
89
master
2,606
require 'spec_helper' describe Metis::Provider do before do @context = Metis::Context.new File.dirname(__FILE__)+"/resources/sample/metis.rb" @context.load end describe '.run' do it 'should return a result' do provider = Metis::Provider.new @context.definitions[:simple], @context provide...
github
krobertson/metis
https://github.com/krobertson/metis
spec/nrpe_packet_spec.rb
Ruby
apache-2.0
89
master
9,079
require 'spec_helper' describe Metis::NrpePacket do describe '#read' do it 'should read a valid request packet' do socket = stub socket.should_receive(:read).and_return("\000\002\000\001e\232\350\211\000{hello world\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\0...
github
krobertson/metis
https://github.com/krobertson/metis
spec/context_spec.rb
Ruby
apache-2.0
89
master
1,131
require 'spec_helper' describe Metis::Context do context "configuration" do it 'should load the specified configuration file' do config_file = File.dirname(__FILE__)+"/resources/sample/metis.rb" IO.should_receive(:read).with(config_file).and_return("") Metis::Context.new(config_file).should_not...
github
krobertson/metis
https://github.com/krobertson/metis
spec/resources/sample/checks/examples.rb
Ruby
apache-2.0
89
master
939
define :simple do execute do ok "we're good" end end define :warning do execute do warn "careful there" end end define :critical do execute do critical "uhh ohh" end end define :error do execute do raise 'booboo' end end define :simple_arg do attribute :name execute do param...
github
markevans/block_helpers
https://github.com/markevans/block_helpers
Rakefile
Ruby
mit
89
master
1,318
require 'rubygems' require 'rake' begin require 'jeweler' Jeweler::Tasks.new do |gem| gem.name = "block_helpers" gem.summary = %Q{An extension to ActionView for adding block helpers to views} gem.email = "mark@new-bamboo.co.uk" gem.homepage = "http://github.com/markevans/block_helpers" gem.auth...
github
markevans/block_helpers
https://github.com/markevans/block_helpers
block_helpers.gemspec
Ruby
mit
89
master
1,605
# 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{block_helpers} s.version = "0.3.3" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :requ...
github
markevans/block_helpers
https://github.com/markevans/block_helpers
lib/block_helpers.rb
Ruby
mit
89
master
2,608
module BlockHelpers class Base class << self def inherited(klass) # Define the helper method # e.g. for a class: # class HelloHelper < BlockHelpers::Base # #..... # end # # then we define a helper method 'hello_helper' # meth...
github
markevans/block_helpers
https://github.com/markevans/block_helpers
spec/spec_helper.rb
Ruby
mit
89
master
547
require 'rubygems' gem 'activesupport' gem 'actionpack' require File.dirname(__FILE__)+'/../lib/block_helpers' # Hacks to get spec/rails to work require 'action_controller' $:.unshift File.dirname(__FILE__)+'/for_spec_rails' RAILS_ENV = 'test' require 'spec' require 'spec/rails' Spec::Runner.configure do |config| en...
github
markevans/block_helpers
https://github.com/markevans/block_helpers
spec/helpers/block_helpers_spec.rb
Ruby
mit
89
master
8,839
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') module TestHelperModule end describe TestHelperModule do describe "simple block_helper" do before(:each) do module TestHelperModule remove_const(:TestHelper) if defined?(TestHelper) class TestHelper < BlockHelpers::...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
union_of.gemspec
Ruby
mit
89
master
1,266
# frozen_string_literal: true require_relative 'lib/union_of/version' Gem::Specification.new do |spec| spec.name = 'union_of' spec.version = UnionOf::VERSION spec.authors = ['Zeke Gabrielse'] spec.email = ['oss@keygen.sh'] spec.summary = 'Create associations that combine multiple Ac...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
spec/union_of_spec.rb
Ruby
mit
89
master
54,570
# frozen_string_literal: true require 'spec_helper' RSpec.describe UnionOf do temporary_table :account do |t| t.timestamps end temporary_table :user do |t| t.references :account, null: true t.string :email t.index :email, unique: true t.timestamps end temporary_table :products do |t| ...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
spec/spec_helper.rb
Ruby
mit
89
master
767
# frozen_string_literal: true require 'union_of' require 'temporary_tables' require 'sql_matchers' require 'active_support' require 'active_support/testing/time_helpers' require 'active_record' require 'logger' ActiveRecord::Base.logger = Logger.new(STDOUT) if ENV.key?('DEBUG') ActiveRecord::Base.establish_connection...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of.rb
Ruby
mit
89
master
751
# frozen_string_literal: true require 'active_support' require 'active_record' require_relative 'union_of/association' require_relative 'union_of/builder' require_relative 'union_of/macro' require_relative 'union_of/preloader' require_relative 'union_of/readonly_association_proxy' require_relative 'union_of/readonly_...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/readonly_association.rb
Ruby
mit
89
master
882
# frozen_string_literal: true module UnionOf class ReadonlyAssociation < ActiveRecord::Associations::CollectionAssociation MUTATION_METHODS = %i[ writer ids_writer insert_record build_record destroy_all delete_all delete_records update_all concat_records ] MUTATION_METHODS.each d...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/builder.rb
Ruby
mit
89
master
294
# frozen_string_literal: true module UnionOf class Builder < ActiveRecord::Associations::Builder::CollectionAssociation private_class_method def self.valid_options(...) = %i[sources class_name inverse_of extend] private_class_method def self.macro = :union_of end end
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/scope.rb
Ruby
mit
89
master
4,257
# frozen_string_literal: true module UnionOf class Scope < ActiveRecord::Associations::AssociationScope private def last_chain_scope(scope, reflection, owner) return super unless reflection.union_of? foreign_klass = reflection.klass foreign_table = reflection.aliased_table primary_k...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/association.rb
Ruby
mit
89
master
374
# frozen_string_literal: true require_relative 'readonly_association' require_relative 'scope' module UnionOf class Association < UnionOf::ReadonlyAssociation def skip_statement_cache?(...) = true # doesn't work with cache def association_scope return if klass.nil? @association_scope ||...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/reflection.rb
Ruby
mit
89
master
3,871
# frozen_string_literal: true module UnionOf class Reflection < ActiveRecord::Reflection::AssociationReflection attr_reader :union_sources def initialize(...) super @union_sources = @options[:sources] end def macro = :union_of def union_of? = true def collec...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/macro.rb
Ruby
mit
89
master
700
# frozen_string_literal: true require_relative 'builder' module UnionOf module Macro extend ActiveSupport::Concern class_methods do def union_of(name, scope = nil, **options, &extension) reflection = UnionOf::Builder.build(self, name, scope, options, &extension) ActiveRecord::Reflect...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/railtie.rb
Ruby
mit
89
master
4,135
# frozen_string_literal require_relative 'macro' require_relative 'preloader' require_relative 'readonly_association_proxy' module UnionOf module ReflectionExtension def add_union_reflection(model, name, reflection) model.union_reflections = model.union_reflections.merge(name.to_s => reflection) end ...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/readonly_association_proxy.rb
Ruby
mit
89
master
539
# frozen_string_literal: true module UnionOf class ReadonlyAssociationProxy < ActiveRecord::Associations::CollectionProxy MUTATION_METHODS = %i[ insert insert! insert_all insert_all! build new create create! upsert upsert_all update_all update! update delete destroy destroy_all delete_all...
github
keygen-sh/union_of
https://github.com/keygen-sh/union_of
lib/union_of/preloader/association.rb
Ruby
mit
89
master
2,518
# frozen_string_literal: true module UnionOf module Preloader class Association < ActiveRecord::Associations::Preloader::ThroughAssociation def load_records(*) preloaded_records # we don't need to load anything except the union associations end def preloaded_records @preloaded_...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
Rakefile
Ruby
apache-2.0
89
main
2,889
require "bundler/gem_tasks" require "tldr/rake" require_relative "lib/tinygql/version" FILES = [ "lib/tinygql/nodes.rb", "lib/tinygql/visitors.rb" ] task :tldr => FILES task default: :tldr def extract_nodes source require "psych" require "erb" info = Psych.load_file source node = Struct.new(:name, :parent,...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
tinygql.gemspec
Ruby
apache-2.0
89
main
671
require_relative "lib/tinygql/version" Gem::Specification.new do |s| s.name = "tinygql" s.version = TinyGQL::VERSION s.summary = "A GraphQL parser" s.description = "Yet another GraphQL parser written in Ruby." s.authors = ["Aaron Patterson"] s.email = "tenderlove@ruby-lang.org" s...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
lib/tinygql/lexer.rb
Ruby
apache-2.0
89
main
8,845
# frozen_string_literal: true require "strscan" module TinyGQL class Lexer IDENTIFIER = /[_A-Za-z][_0-9A-Za-z]*\b/ IGNORE = %r{ (?: [, \c\r\n\t]+ | \#.*$ )* }x INT = /[-]?(?:[0]|[1-9][0-9]*)/ FLOAT_DECIMAL = /[.][0-9]+/ FLOAT_EXP = /[eE][+...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
lib/tinygql/parser.rb
Ruby
apache-2.0
89
main
17,537
# frozen_string_literal: true require "tinygql/lexer" require "tinygql/nodes" module TinyGQL class Parser class UnexpectedToken < StandardError; end def self.parse doc new(doc).parse end def initialize doc @lexer = Lexer.new doc accept_token end def parse document ...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
bin/bench.rb
Ruby
apache-2.0
89
main
1,233
# frozen_string_literal: true require "tinygql" require "benchmark/ips" source = File.read(File.expand_path("../test/kitchen-sink.graphql", __dir__)) files = Dir[File.join(File.expand_path("../benchmark", __dir__), "**/*")].select { |f| File.file? f } Benchmark.ips do |x| x.report "kitchen-sink" do TinyGQL.pa...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
bin/make_hash.rb
Ruby
apache-2.0
89
main
1,030
require "tinygql" # Calculate a perfect hash for GraphQL keywords def bits x count = 0 while x > 0 count += 1 x >>= 1 end count end # on is too short, and subscription is the longest. # The lexer can easily detect them by length, so lets calculate a perfect # hash for the rest. kws = TinyGQL::Lexer::...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
test/parser_test.rb
Ruby
apache-2.0
89
main
8,779
require "helper" require "tinygql" module TinyGQL class ParserTest < Test def test_homogeneous_ast %w{ kitchen-sink.graphql schema-extensions.graphql schema-kitchen-sink.graphql }.each do |f| ast = Parser.parse File.read(File.join(__dir__, f)) assert ast.all? { |x| x.is_a?(TinyGQL::Nodes::N...
github
tenderlove/tinygql
https://github.com/tenderlove/tinygql
test/lexer_test.rb
Ruby
apache-2.0
89
main
4,981
require "helper" module TinyGQL class LexerTest < Test PUNC_LUT = {"!"=>[:BANG, "!"], "$"=>[:VAR_SIGN, "$"], "("=>[:LPAREN, "("], ")"=>[:RPAREN, ")"], "..."=>[:ELLIPSIS, "..."], ":"=>[:COLON, ":"], "="=>[:EQUALS, "="]...
github
lululau/proxy-switcher-alfred-workflow
https://github.com/lululau/proxy-switcher-alfred-workflow
alfred.rb
Ruby
mit
89
master
5,016
#!/usr/bin/env ruby require "delegate" class String def to_argv argv = [] meta_char_stack = [] arg = nil idx = 0 while idx < self.size char = self[idx] top = meta_char_stack.last case char when %{"} case top when %{"} meta_char_stack.pop ...
github
lululau/proxy-switcher-alfred-workflow
https://github.com/lululau/proxy-switcher-alfred-workflow
proxy_switcher.rb
Ruby
mit
89
master
5,028
#!/usr/bin/env ruby require "yaml" require_relative "alfred" class ProxySwitcher class Config attr :proxies CONFIG_FILE = File.expand_path '~/.proxyswitcher.rc' def initialize(service='Wi-Fi') if test ?e, CONFIG_FILE @proxies = YAML.load(IO.read(CONFIG_FILE)).map { |k, v| ProxyOption.b...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
ubuntu-machine.gemspec
Ruby
mit
89
master
1,742
Gem::Specification.new do |s| s.name = "ubuntu-machine" s.version = "0.5.3.2" s.date = "2009-05-09" s.summary = "Capistrano recipes for setting up and deploying to a Ubuntu Machine" s.email = "thomas@suitmymind.com" s.homepage = "http://suitmymind.github.com/ubuntu-machine" s.description = "C...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine.rb
Ruby
mit
89
master
1,530
unless Capistrano::Configuration.respond_to?(:instance) abort "Requires Capistrano 2" end # Dir["#{File.dirname(__FILE__)}/ubuntu-machine/*.rb"].each { |lib| # Capistrano::Configuration.instance.load {load(lib)} # } Capistrano::Configuration.instance.load {load("#{File.dirname(__FILE__)}/ubuntu-machine/apache...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/machine.rb
Ruby
mit
89
master
1,557
namespace :machine do desc "Change the root password, create a new user and allow him to sudo and to SSH" task :initial_setup do set :user_to_create , user set :user, 'root' run_and_watch_prompt("passwd", [/Enter new UNIX password/, /Retype new UNIX password:/]) run_and_watch_prompt("addu...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/aptitude.rb
Ruby
mit
89
master
3,314
namespace :aptitude do desc <<-DESC Updates your software package list. This will not "upgrade" any of your \ installed software. See "Update" section on \ http://articles.slicehost.com/2007/11/6/ubuntu-gutsy-setup-page-2 DESC task :update, :roles => :app do sudo "apt-get update" end des...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/git.rb
Ruby
mit
89
master
471
namespace :git do desc "Install git" task :install, :roles => :app do sudo "sudo apt-get build-dep git-core -y" run "wget http://kernel.org/pub/software/scm/git/#{git_version}.tar.gz" run "tar xvzf #{git_version}.tar.gz" run "cd #{git_version}" run "cd #{git_version} && ./configure" run "cd ...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/apache.rb
Ruby
mit
89
master
3,726
namespace :apache do desc "Install Apache" task :install, :roles => :web do sudo "apt-get install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert -y" run "cat /etc/apache2/apache2.conf > ~/apache2.conf.tmp" put render("apache2", binding), "apache2.append.conf.tmp" ...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/utils.rb
Ruby
mit
89
master
1,111
namespace :utils do desc "Reboot the system." task :reboot, :roles => :gateway do sure = Capistrano::CLI.ui.ask("Are you sure you want to reboot now? (y/n) : ") sudo "reboot" if sure=="y" end desc "Force a reboot of the system." task :force_reboot, :roles => :gateway do sudo "reboot" end ...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/ruby.rb
Ruby
mit
89
master
2,872
require 'net/http' namespace :ruby do desc "Install Ruby 1.8" task :install, :roles => :app do sudo "apt-get install -y ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8" sudo "apt-get install -y libmysql-ruby1.8" sudo "ln -s /usr/bin/ru...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/mysql.rb
Ruby
mit
89
master
2,639
#TODO : change root password namespace :mysql do desc "Restarts MySQL database server" task :restart, :roles => :db do sudo "/etc/init.d/mysql restart" end desc "Starts MySQL database server" task :start, :roles => :db do sudo "/etc/init.d/mysql start" end desc "Stops MySQL database server" t...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/gems.rb
Ruby
mit
89
master
1,150
namespace :gems do desc "Install RubyGems" task :install_rubygems, :roles => :app do run "wget http://rubyforge.org/frs/download.php/45905/rubygems-#{rubygem_version}.tgz" run "tar xvzf rubygems-#{rubygem_version}.tgz" run "cd rubygems-#{rubygem_version} && sudo ruby setup.rb" sudo "ln -s /usr/bin/g...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/helpers.rb
Ruby
mit
89
master
1,174
require 'erb' # render a template def render(file, binding) template = File.read("#{File.dirname(__FILE__)}/templates/#{file}.erb") result = ERB.new(template).result(binding) end # allows to sudo a command which require the user input via the prompt def sudo_and_watch_prompt(cmd, regex_to_watch) sudo cmd, :pty ...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/iptables.rb
Ruby
mit
89
master
788
namespace :iptables do desc <<-DESC Harden iptables configuration. Only allows ssh, http, and https connections and packets from SAN. See "iptables" section on \ http://articles.slicehost.com/2008/4/25/ubuntu-hardy-setup-page-1 DESC task :configure, :roles => :gateway do sudo "apt-get install ipt...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/php.rb
Ruby
mit
89
master
339
namespace :php do desc "Install PHP 5" task :install, :roles => :app do sudo "apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-imagick php5-mcrypt php5-memcache php5-mhash php5-mysql php5-pspell php5-snmp php5-sqlite php5-xmlrpc php5-xsl -y" sudo "/etc/init.d/apache2 ...
github
tbalthazar-archives/ubuntu-machine
https://github.com/tbalthazar-archives/ubuntu-machine
lib/capistrano/ext/ubuntu-machine/ssh.rb
Ruby
mit
89
master
2,147
namespace :ssh do desc <<-DESC Setup SSH on the gateway host. Runs `upload_keys`, `install_ovh_ssh_key` AND \ `configure_sshd` then reloads the SSH service to finalize the changes. DESC task :setup, :roles => :gateway do upload_keys configure_sshd install_ovh_ssh_key if ["ovh-rps", "ovh-ded...
github
toy/dump
https://github.com/toy/dump
Appraisals
Ruby
mit
89
main
3,298
# frozen_string_literal: true def appgen(gems) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity description = gems.map{ |name, version| "#{name} #{version}" }.join(', ') appraise "ruby-#{RUBY_VERSION[/\d+\.\d+/]} #{description}" do rails_version...
github
toy/dump
https://github.com/toy/dump
dump.gemspec
Ruby
mit
89
main
1,188
# encoding: UTF-8 Gem::Specification.new do |s| s.name = 'dump' s.version = '1.3.0' s.summary = %q{Rails app rake and capistrano tasks to create and restore dumps of database and assets} s.homepage = "https://github.com/toy/#{s.name}" s.authors = ['Ivan Kuchin'] s.license = 'MIT' ...
github
toy/dump
https://github.com/toy/dump
Gemfile
Ruby
mit
89
main
227
# frozen_string_literal: true source 'https://rubygems.org' gemspec gem 'rake', '< 12.3' if RUBY_VERSION < '2.0' gem 'appraisal', *RUBY_VERSION < '2.3' ? ['< 2.3'] : ['>= 2.5'] if RUBY_VERSION >= '4' gem 'benchmark' end
github
toy/dump
https://github.com/toy/dump
lib/dump.rb
Ruby
mit
89
main
2,202
# encoding: UTF-8 # frozen_string_literal: true require 'fileutils' require 'rake' require 'progress' require 'dump/rails_root' require 'dump/snapshot' require 'dump/reader' require 'dump/writer' require 'dump/env' require 'dump/railtie' if defined?(Rails::Railtie) # Main interface module Dump class << self ...
github
toy/dump
https://github.com/toy/dump
lib/dump/snapshot.rb
Ruby
mit
89
main
4,654
# encoding: UTF-8 # frozen_string_literal: true require 'dump/rails_root' require 'dump/table_manipulation' require 'pathname' module Dump # Base class for dump class Snapshot include TableManipulation def self.list(options = {}) dumps = Dir[File.join(Dump.rails_root, 'dump', options[:all] ? '*.*' ...
github
toy/dump
https://github.com/toy/dump
lib/dump/continious_timeout.rb
Ruby
mit
89
main
769
# frozen_string_literal: true # based on Timeout module Dump # Timeout if does not finish or defer in requested time module ContiniousTimeout class TimeoutException < RuntimeError; end class RestartException < RuntimeError; end # Object with defer method class Deferer def initialize(thread...
github
toy/dump
https://github.com/toy/dump
lib/dump/capistrano.rb
Ruby
mit
89
main
210
# frozen_string_literal: true require 'capistrano/version' unless defined?(Capistrano::Version) && Capistrano::Version::MAJOR == 2 fail 'Capistrano 3 is not yet supported' end require 'dump/capistrano/v2'
github
toy/dump
https://github.com/toy/dump
lib/dump/writer.rb
Ruby
mit
89
main
4,299
# frozen_string_literal: true require 'dump/snapshot' require 'dump/archive_tar_minitar' require 'dump/assets' require 'progress' require 'rake' require 'zlib' require 'tempfile' module Dump # Creating dump class Writer < Snapshot attr_reader :stream, :config def self.create(path) new(path).open do...
github
toy/dump
https://github.com/toy/dump
lib/dump/railtie.rb
Ruby
mit
89
main
204
# frozen_string_literal: true module Dump # Add rake tasks to rails app class Railtie < Rails::Railtie rake_tasks do load 'tasks/assets.rake' load 'tasks/dump.rake' end end end
github
toy/dump
https://github.com/toy/dump
lib/dump/rails_root.rb
Ruby
mit
89
main
374
# encoding: UTF-8 # frozen_string_literal: true module Dump # Get rails app root (Rails.root or RAILS_ROOT or fail) module RailsRoot def rails_root case when defined?(Rails) Rails.root when defined?(RAILS_ROOT) RAILS_ROOT else fail 'Unknown rails app root' ...
github
toy/dump
https://github.com/toy/dump
lib/dump/env.rb
Ruby
mit
89
main
4,643
# encoding: UTF-8 # frozen_string_literal: true require 'dump/env/filter' module Dump # Working with environment variables module Env DICTIONARY = { :desc => %w[DESC DESCRIPTION], :like => %w[LIKE VER VERSION], :tags => %w[TAGS TAG], :leave => %w[LEAVE], :summary => %w[SUMMARY], ...
github
toy/dump
https://github.com/toy/dump
lib/dump/table_manipulation.rb
Ruby
mit
89
main
4,373
# frozen_string_literal: true require 'dump/env' module Dump # Methods to work with db using ActiveRecord module TableManipulation protected def schema_tables %w[schema_info schema_migrations] end def verify_connection if connection.method(:verify!).arity == 1 connection.verify...
github
toy/dump
https://github.com/toy/dump
lib/dump/archive_tar_minitar.rb
Ruby
mit
89
main
229
# frozen_string_literal: true require 'archive/tar/minitar' Archive::Tar::Minitar::Reader::EntryStream.class_eval do def getbyte return nil if @read >= @size ret = @io.getbyte @read += 1 if ret ret end end
github
toy/dump
https://github.com/toy/dump
lib/dump/reader.rb
Ruby
mit
89
main
8,331
# frozen_string_literal: true require 'dump/snapshot' require 'dump/archive_tar_minitar' require 'dump/assets' require 'progress' require 'rake' require 'zlib' require 'tempfile' module Dump # Reading dump class Reader < Snapshot attr_reader :stream, :config def self.restore(path) new(path).open do...
github
toy/dump
https://github.com/toy/dump
lib/dump/assets.rb
Ruby
mit
89
main
607
# encoding: UTF-8 # frozen_string_literal: true require 'dump' module Dump # Helper for listing assets for dump module Assets SPLITTER = /[:,]/.freeze class << self def assets File.readlines(File.join(Dump.rails_root, 'config/assets')).map(&:strip).grep(/^[^#]/).join(':') end d...
github
toy/dump
https://github.com/toy/dump
lib/dump/capistrano/v2.rb
Ruby
mit
89
main
11,063
# encoding: UTF-8 # frozen_string_literal: true require 'fileutils' require 'shellwords' require 'dump/continious_timeout' require 'dump/env' require 'active_support/core_ext/object/blank' require 'English' Capistrano::Configuration.instance(:i_need_this!).load do namespace :dump do def dump_command(command,...
github
toy/dump
https://github.com/toy/dump
lib/dump/env/filter.rb
Ruby
mit
89
main
815
# encoding: UTF-8 # frozen_string_literal: true module Dump module Env # Filter strings by simple pattern: # 'a,b,c' will pass only 'a', 'b' and 'c' # '-a,b,c' will pass everything except 'a', 'b' and 'c' class Filter attr_reader :invert, :values, :transparent def initialize(string, ...
github
toy/dump
https://github.com/toy/dump
lib/tasks/assets.rake
Ruby
mit
89
main
410
# frozen_string_literal: true require 'dump' task :assets do ENV['ASSETS'] ||= Dump::Assets.assets end namespace :assets do desc "Delete assets#{Dump::Env.explain_variables_for_command(:assets)}" task :delete => :assets do ENV['ASSETS'].split(':').each do |asset| Dump::Assets.glob_asset_children(asse...
github
toy/dump
https://github.com/toy/dump
lib/tasks/dump.rake
Ruby
mit
89
main
853
# frozen_string_literal: true require 'dump' desc "Short for dump:create#{Dump::Env.explain_variables_for_command(:create)}" task :dump => 'dump:create' namespace :dump do desc "Show avaliable versions#{Dump::Env.explain_variables_for_command(:versions)}" task :versions => :environment do Dump.versions(Dump:...
github
toy/dump
https://github.com/toy/dump
lib/generators/assets_config/assets_config_generator.rb
Ruby
mit
89
main
530
# frozen_string_literal: true case when defined?(Rails::Generator::Base) # Generator for rails < 3 class AssetsConfigGenerator < Rails::Generator::Base def manifest record do |m| m.file 'assets', 'config/assets' end end end when defined?(Rails::Generators::Base) # Generator for rail...
github
toy/dump
https://github.com/toy/dump
spec/dump_spec.rb
Ruby
mit
89
main
12,129
# frozen_string_literal: true require 'spec_helper' require 'dump' describe Dump do describe 'versions' do it 'calls Snapshot.list if called without version' do expect(Dump::Snapshot).to receive(:list).and_return([]) described_class.versions end it 'calls Snapshot.list with options if calle...
github
toy/dump
https://github.com/toy/dump
spec/cycle_spec.rb
Ruby
mit
89
main
6,344
# frozen_string_literal: true require 'spec_helper' require 'dump' require 'tmpdir' class Chicken < ActiveRecord::Base end ActiveRecord::Base.logger = Logger.new(File.join(Dump.rails_root, 'log/dump.log')) def database_configs YAML.load_file(File.expand_path('../db/database.yml', __FILE__)) end def adapters da...
github
toy/dump
https://github.com/toy/dump
spec/spec_helper.rb
Ruby
mit
89
main
345
# frozen_string_literal: true ENV['RAILS_ENV'] ||= 'test' require 'dummy_rails_app' def grab_output real_stdout, $stdout = $stdout, StringIO.new real_stderr, $stderr = $stderr, StringIO.new begin yield {:stdout => $stdout.string, :stderr => $stderr.string} ensure $stdout = real_stdout $stderr...
github
toy/dump
https://github.com/toy/dump
spec/dummy_rails_app.rb
Ruby
mit
89
main
1,176
# frozen_string_literal: true require 'rails/version' version = Rails::VERSION::STRING if version < '3' && !Gem.respond_to?(:source_index) # Add Gem.source_index for rails < 3 module Gem def self.source_index sources end SourceIndex = Specification end end # Construct possible paths for conf...
github
toy/dump
https://github.com/toy/dump
spec/dummy-4.0/config/application.rb
Ruby
mit
89
main
1,231
require File.expand_path('../boot', __FILE__) # Pick the frameworks you want: require "active_record/railtie" require "action_controller/railtie" require "action_mailer/railtie" # require "sprockets/railtie" # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems # you've limited ...
github
toy/dump
https://github.com/toy/dump
spec/dummy-4.0/config/routes.rb
Ruby
mit
89
main
1,606
Dummy40::Application.routes.draw do # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" # root 'welcome#index' # Example of regular route: # get 'products/:id' => ...
github
toy/dump
https://github.com/toy/dump
spec/dummy-4.0/config/environments/development.rb
Ruby
mit
89
main
913
Dummy40::Application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web s...