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 | mozamimy/nymphia | https://github.com/mozamimy/nymphia | nymphia.gemspec | Ruby | mit | 19 | master | 1,042 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'nymphia/version'
Gem::Specification.new do |spec|
spec.name = 'nymphia'
spec.version = Nymphia::VERSION
spec.authors = ['mozamimy (Moza USANE)']
spec.email = ... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | examples/company.rb | Ruby | mit | 19 | master | 1,133 | identity_file :company, '~/.ssh/id_rsa.company'
identity_file :company_gateway, '~/.ssh/id_rsa.company.gw'
identity_file :company_internal, '~/.ssh/id_rsa.company.in'
gateway('company.gateway', 'Gateway saerver of my company') {
hostname 'gw.example.com'
user 'alice'
port 19822
}
group('company.ap-northeast-1')... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | examples/base.rb | Ruby | mit | 19 | master | 364 | identity_file :private, '~/.ssh/id_rsa.1'
my_server_port = 4321
host('alice', 'my server on VPS') {
hostname 'alice.example.com'
user 'alice'
port my_server_port
use_identify_file :private
}
host('queen', 'NAS in my home network') {
hostname '172.16.16.3'
user 'alice'
port my_server_port
use_identify... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | spec/nymphia/cli_spec.rb | Ruby | mit | 19 | master | 947 | require 'spec_helper'
describe Nymphia::DSL do
describe '#run' do
context 'when -f is given' do
subject(:cli) { Nymphia::CLI.new(['-f', 'examples/base.rb']) }
it 'contains nymphia header in stdout' do
expect { subject.run }.to output(/# This config is generated by Nymphia/).to_stdout_from_an... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | spec/nymphia/dsl_spec.rb | Ruby | mit | 19 | master | 455 | require 'spec_helper'
require 'timecop'
describe Nymphia::DSL do
subject(:dsl) { Nymphia::DSL.new('', '') }
describe '#render' do
before { Timecop.freeze(2016, 11, 21, 23, 35, 47) }
after { Timecop.return }
it 'contains date and time in ISO 8601 format' do
output = StringIO.new
dsl.compi... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | spec/nymphia/dsl/context_spec.rb | Ruby | mit | 19 | master | 341 | require 'spec_helper'
describe Nymphia::DSL::Context do
context 'Loading DSL file has `load` method' do
it 'emits warning message' do
expect {
Nymphia::DSL::Context.eval('load "examples/company.rb"', 'dummy')
}.to output(/#load method is obsolated. Use #include_file/).to_stderr_from_any_proce... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | spec/nymphia/dsl/context/host_context_methods_spec.rb | Ruby | mit | 19 | master | 745 | require 'spec_helper'
describe Nymphia::DSL::Context::HostContextMethods do
class Anonymous
include Nymphia::DSL::Context::HostContextMethods
def initialize
@result = {
contents: {},
}
@context = {
identity_files: {
'private' => '~/.ssh/private.pem',
'c... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | spec/nymphia/dsl/context/use_gateway_spec.rb | Ruby | mit | 19 | master | 377 | require 'spec_helper'
describe Nymphia::DSL::Context::UseGateway do
subject(:use_gateway) { Nymphia::DSL::Context::UseGateway.new('context', 'name') }
describe '.new' do
it 'has @context and @result' do
expect(use_gateway.instance_variable_get(:@context)).to eq 'context'
expect(use_gateway.instanc... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia.rb | Ruby | mit | 19 | master | 444 | module Nymphia; end
require 'nymphia/cli'
require 'nymphia/dsl'
require 'nymphia/version'
require 'nymphia/dsl/recursive_methods'
require 'nymphia/dsl/context'
require 'nymphia/dsl/context/host_context_methods'
require 'nymphia/dsl/context/default_params'
require 'nymphia/dsl/context/use_gateway'
require 'nymphia/dsl/... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl.rb | Ruby | mit | 19 | master | 543 | require 'time'
require 'erb'
require 'pathname'
module Nymphia
class DSL
def initialize(dsl_code, path)
@dsl_code = dsl_code
@path = path
end
def compile
@result = Nymphia::DSL::Context.eval(@dsl_code, @path).result
end
def render(output)
ssh_config = ERB.new(File.read(f... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/cli.rb | Ruby | mit | 19 | master | 1,155 | require 'nymphia'
require 'optparse'
require 'pathname'
module Nymphia
class CLI
def self.start(argv)
new(argv).run
end
def initialize(argv)
@argv = argv.dup
parser.parse!(@argv)
end
def run
validate_args!
dsl_code_file = File.open(@file_path)
absolute_dsl_f... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context.rb | Ruby | mit | 19 | master | 1,118 | require 'pathname'
module Nymphia
class DSL
class Context
include RecursiveMethods
attr_reader :result
def self.eval(dsl_code, path)
new(path) do
eval(dsl_code, binding, path)
end
end
def initialize(path, &block)
@path = path
@context = ... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/recursive_methods.rb | Ruby | mit | 19 | master | 1,645 | module Nymphia
class DSL
module RecursiveMethods
private
def default_params(&block)
new_default_params = Nymphia::DSL::Context::DefaultParams.new(@context, &block).result[:contents]
@context[:default_params][@group_name] = new_default_params
end
def use_gateway(name)
... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/host_context_methods.rb | Ruby | mit | 19 | master | 940 | module Nymphia
class DSL
class Context
module HostContextMethods
private
def use_identify_file(*identity_file_ids)
@result[:contents]['IdentityFile'] = []
identity_file_ids.each do |identity_file_id|
@result[:contents]['IdentityFile'] << @context[:identity_f... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/proxy.rb | Ruby | mit | 19 | master | 756 | module Nymphia
class DSL
class Context
class Proxy < Host
def initialize(context, name, description, default_params, gateway_usage, &block)
super(context, name, description, default_params, gateway_usage, &block)
end
def local_forward(name, params)
name = name.to... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/group.rb | Ruby | mit | 19 | master | 360 | module Nymphia
class DSL
class Context
class Group
include RecursiveMethods
attr_reader :result
def initialize(context, name, &block)
@group_name = name
@context = context
@result = {
hosts: [],
}
instance_eval(&block)
... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/gateway.rb | Ruby | mit | 19 | master | 331 | module Nymphia
class DSL
class Context
class Gateway < Host
def initialize(context, name, description, default_params, gateway_usage, &block)
super(context, name, description, default_params, gateway_usage, &block)
@context[:gateways][name] = @result
end
end
end... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/use_gateway.rb | Ruby | mit | 19 | master | 229 | module Nymphia
class DSL
class Context
class UseGateway
attr_reader :result
def initialize(context, name)
@context = context
@result = name
end
end
end
end
end |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/default_params.rb | Ruby | mit | 19 | master | 338 | module Nymphia
class DSL
class Context
class DefaultParams
include HostContextMethods
attr_reader :result
def initialize(context, &block)
@context = context
@result = {
contents: {},
}
instance_eval(&block)
end
end
... |
github | mozamimy/nymphia | https://github.com/mozamimy/nymphia | lib/nymphia/dsl/context/host.rb | Ruby | mit | 19 | master | 1,100 | module Nymphia
class DSL
class Context
class Host
include HostContextMethods
attr_reader :result
def initialize(context, name, description, default_params, gateway_usage, &block)
@host_name = name
@context = context.merge(host_name: name)
@result = {
... |
github | udzura/populus | https://github.com/udzura/populus | Rakefile | Ruby | apache-2.0 | 19 | master | 349 | require "bundler/gem_tasks"
require "rake/testtask"
desc 'Run test_unit based test'
Rake::TestTask.new do |t|
# To run test for only one file (or file path pattern)
# $ bundle exec rake test TEST=test/test_specified_path.rb
t.libs.concat ["test"]
t.test_files = Dir["test/**/test_*.rb"]
t.verbose = true
t.r... |
github | udzura/populus | https://github.com/udzura/populus | populus.gemspec | Ruby | apache-2.0 | 19 | master | 1,128 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'populus/version'
Gem::Specification.new do |spec|
spec.name = "populus"
spec.version = Populus::VERSION
spec.authors = ["Uchio, KONDO"]
spec.email = ["udzura@... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus.rb | Ruby | apache-2.0 | 19 | master | 435 | module Populus; end
require "logger"
require "populus/default_logger"
module Populus
class << self
attr_accessor :consul_bin, :logger
end
self.consul_bin = 'consul' # default to count on $PATH
self.logger = Populus::DefaultLogger
end
require "populus/pool"
require "populus/helpers"
require "populus/conf... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/daemon.rb | Ruby | apache-2.0 | 19 | master | 454 | require 'populus/watch_thread'
require 'securerandom'
module Populus
module Daemon
def self.run(setting: nil)
raise ArgumentError unless setting
Populus.eval_setting(setting)
threads = Populus::Pool.gen_threads
trap(:INT) do
STDERR.puts "Caught SIGINT. Quitting..."
thread... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/accepter.rb | Ruby | apache-2.0 | 19 | master | 1,366 | require 'populus/remote_runner'
require 'populus/node'
module Populus
class Accepter
# TODO: validators
class Base
attr_accessor :condition, :runner, :metadata
def initialize(cond: nil, runs: nil, metadata: {})
self.condition = cond
self.runner = runs
self.metadata = meta... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/remote_runner.rb | Ruby | apache-2.0 | 19 | master | 1,319 | require 'specinfra'
require 'erb'
require 'tempfile'
require 'fileutils'
module Populus
class RemoteRunner
def initialize(backend, &run_it)
@backend = backend
instance_exec(&run_it)
end
def execute(*command)
Populus.logger.info("Running command: %s" % command.inspect)
res = @bac... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/default_logger.rb | Ruby | apache-2.0 | 19 | master | 554 | require 'logger'
require 'colorize'
module Populus
class DefaultLoggerFormatter < ::Logger::Formatter
COLOR_CODE = {
'DEBUG' => :black,
'INFO' => :green,
'WARN' => :yellow,
'ERROR' => :red,
'FATAL' => :magenta,
}
def call(severity, time, progname, msg)
s = super
... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/pool.rb | Ruby | apache-2.0 | 19 | master | 612 | require 'singleton'
require 'json'
module Populus
class Pool
include Singleton
def objects
@objects ||= []
end
class << self
def register_object(o)
instance.objects << o
Populus.logger.info "Registered: #{o.inspect}"
end
# TODO: Trying Enumerable#lazy
... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/watch_thread.rb | Ruby | apache-2.0 | 19 | master | 931 | require 'thread'
require 'open3'
require 'populus/pool'
require 'json'
module Populus
class WatchThread
def self.consul_watch(*args)
wait = Thread.fork do
begin
stdin, stdout, stderr = *Open3.popen3(
Populus.consul_bin, 'watch', *args, '/bin/cat'
)
stdin.c... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/configuration.rb | Ruby | apache-2.0 | 19 | master | 725 | require 'populus'
module Populus
class Configuration
def initialize
@pool = {}
end
def set(key, value)
true_value = case value
when Proc
value
else
lambda { value }
end
self.define_single... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/helpers.rb | Ruby | apache-2.0 | 19 | master | 381 | require 'populus/accepter'
module Populus
module Helpers
extend self
def define_helper(name, &block)
m = Module.new do
define_method(name, &block)
end
Populus.logger.info "Register helper: #{name}"
Accepter::Base.send :include, m
end
end
end
Dir.glob("#{File.dirname __... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/dsl.rb | Ruby | apache-2.0 | 19 | master | 1,451 | require 'populus/pool'
require 'populus/node'
require 'populus/accepter'
module Populus
# Populus.node 'web001.exapmle.jp', 'web002.exapmle.jp'
#
# Populus.watch :event, name: "sample" do
# cond {|data| data.has_key?('Payload') }
# runs do |data|
# Populus.logger.info Base64.decode(data['Payload']... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/node.rb | Ruby | apache-2.0 | 19 | master | 442 | require 'specinfra'
module Populus
class Node
class << self
def registry
@nodes ||= {}
end
def register_host(hostname)
registry[hostname] = gen_host(hostname)
end
private
def gen_host(hostname)
return Specinfra::Backend::Ssh.new(
host: hostn... |
github | udzura/populus | https://github.com/udzura/populus | lib/populus/helpers/slack.rb | Ruby | apache-2.0 | 19 | master | 341 | require 'populus/helpers'
require 'slack-notifier'
Populus::Helpers.define_helper :notify_to_slack do |message, options={}|
notifier = Slack::Notifier.new Populus.config.slack_webhook
notifier.channel = options[:channel] if options[:channel]
notifier.username = options[:username] if options[:username]
notif... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | Rakefile | Ruby | mit | 19 | master | 341 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/test_*.rb"]
end
require "rubocop/rake_task"
RuboCop::RakeTask.new
require "rubocop_runner/rake_task"
RubocopRunner::RakeTask.new
... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | receptacle.gemspec | Ruby | mit | 19 | master | 1,457 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "receptacle/version"
Gem::Specification.new do |spec|
spec.name = "receptacle"
spec.version = Receptacle::VERSION
spec.authors = ["Andreas Eger"]
spec.email... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | Guardfile | Ruby | mit | 19 | master | 1,206 | # frozen_string_literal: true
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
## Not... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | examples/simple_repo.rb | Ruby | mit | 19 | master | 2,575 | #!/usr/bin/env ruby
# frozen_string_literal: true
require "bundler/inline"
gemfile true do
source "https://rubygems.org"
gem "receptacle", "~>0.3"
gem "mongo"
end
require "irb"
# a simple struct to act as business entity
User = Struct.new(:id, :name)
# we have a global mongo connection which can be easily reus... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle.rb | Ruby | mit | 19 | master | 289 | # frozen_string_literal: true
require "receptacle/version"
require "receptacle/interface_methods"
require "receptacle/method_delegation"
module Receptacle
module Repo
def self.included(base)
base.extend(InterfaceMethods)
base.extend(MethodDelegation)
end
end
end |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/method_delegation.rb | Ruby | mit | 19 | master | 5,702 | # frozen_string_literal: true
require "receptacle/method_cache"
require "receptacle/registration"
require "receptacle/errors"
module Receptacle
# module which enables a repository to mediate methods dynamically to wrappers and strategy
# @api private
module MethodDelegation
# dynamically build mediation met... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/registration.rb | Ruby | mit | 19 | master | 966 | # frozen_string_literal: true
require "singleton"
require "set"
module Receptacle
# keeps global state of repositories, the defined strategy, set wrappers and methods to mediate
class Registration
include Singleton
Tuple = Struct.new(:strategy, :wrappers, :methods) # rubocop:disable Lint/StructNewOverride
... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/method_cache.rb | Ruby | mit | 19 | master | 1,732 | # frozen_string_literal: true
module Receptacle
# Cache describing which strategy and wrappers need to be applied for this method
# @api private
class MethodCache
# @return [Symbol] name of the method this cache belongs to
attr_reader :method_name
# @return [Class] strategy class currently setup
... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/errors.rb | Ruby | mit | 19 | master | 323 | # frozen_string_literal: true
module Receptacle
module Errors
class NotConfigured < StandardError
attr_reader :repo
def initialize(repo:)
@repo = repo
super("Missing Configuration for repository: <#{repo}>")
end
end
class ReservedMethodName < StandardError; end
end
e... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/interface_methods.rb | Ruby | mit | 19 | master | 1,707 | # frozen_string_literal: true
require "receptacle/registration"
require "receptacle/errors"
module Receptacle
module InterfaceMethods
RESERVED_METHOD_NAMES = Set.new(%i[wrappers mediate strategy delegate_to_strategy])
private_constant :RESERVED_METHOD_NAMES
# registers a method_name for the to be media... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | lib/receptacle/test_support.rb | Ruby | mit | 19 | master | 2,108 | # frozen_string_literal: true
module Receptacle
module TestSupport
# with_strategy
#
# provides helpful method to toggle strategies during testing
#
# can be used in rspec like this
#
# require 'receptacle/test_support'
# RSpec.configure do |c|
# c.include Receptacle::T... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | performance/profile.rb | Ruby | mit | 19 | master | 1,059 | #!/usr/bin/env ruby
# frozen_string_literal: true
# run with --profile.api in JRUBY_OPTS
require "bundler/inline"
require "jruby/profiler"
PROFILE_NAME = "receptacle"
gemfile false do
source "https://rubygems.org"
gem "receptacle", path: "./.."
end
require_relative "speed_receptacle"
Speed.strategy(Speed::Strate... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | performance/benchmark.rb | Ruby | mit | 19 | master | 1,349 | # frozen_string_literal: true
require "bundler/inline"
gemfile false do
source "https://rubygems.org"
gem "benchmark-ips"
gem "receptacle", path: "./.."
end
require_relative "speed_receptacle"
Speed.strategy(Speed::Strategy::One)
Speed.wrappers [Speed::Wrappers::W1,
Speed::Wrappers::W2,
... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | performance/speed_receptacle.rb | Ruby | mit | 19 | master | 1,510 | # frozen_string_literal: true
require "receptacle"
module Speed
include Receptacle::Repo
mediate :a
mediate :b
mediate :c
mediate :d
mediate :e
mediate :f
mediate :g
module Strategy
class One
def a(arg)
arg
end
alias b a
alias c a
alias d a
alias e a
... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | test/fixture.rb | Ruby | mit | 19 | master | 4,395 | # frozen_string_literal: true
require "receptacle"
module Fixtures
def self.callstack
Thread.current[:receptacle_test_callstack] ||= []
end
module Test
include Receptacle::Repo
mediate :a
mediate :b
mediate :c
mediate :d
mediate :e
end
module Strategy
class One
def a(... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | test/test_receptacle.rb | Ruby | mit | 19 | master | 10,214 | # frozen_string_literal: true
require "test_helper"
require "count_down_latch"
require "fixture"
class ReceptacleTest < Minitest::Test
def callstack
Thread.current[:receptacle_test_callstack]
end
def receptacle
Fixtures::Test
end
def clear_callstack
Thread.current[:receptacle_test_callstack] =... |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | test/test_helper.rb | Ruby | mit | 19 | master | 244 | # frozen_string_literal: true
unless RUBY_PLATFORM == "java"
require "simplecov"
SimpleCov.start do
add_filter "/test/"
end
end
$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "receptacle"
require "minitest/autorun" |
github | andreaseger/receptacle | https://github.com/andreaseger/receptacle | test/count_down_latch.rb | Ruby | mit | 19 | master | 519 | # frozen_string_literal: true
class CountDownLatch
attr_reader :count
def initialize(to)
@count = to.to_i
raise ArgumentError.new("cannot count down from negative integer") unless @count >= 0
@lock = Mutex.new
@condition = ConditionVariable.new
end
def count_down
@lock.synchronize do
... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | Gemfile | Ruby | mit | 19 | master | 1,775 | source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.4'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails'#, '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See htt... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | config/application.rb | Ruby | mit | 19 | master | 1,119 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module ChunkedRails
class Application < Rails::Application
# Settings in config/environments/* take ... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | config/routes.rb | Ruby | mit | 19 | master | 1,904 | Rails.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 'courses#index'
resources :courses do
member do
get 'upload', to: ... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | config/environments/development.rb | Ruby | mit | 19 | master | 1,680 | Rails.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 serv... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | app/models/course.rb | Ruby | mit | 19 | master | 800 | class Course < ActiveRecord::Base
# Variables
COURSE_STATUSES = %w(new uploading uploaded)
# Validations
validates :name, presence: true
validates :status, inclusion: { in: COURSE_STATUSES }
# Paperclip
has_attached_file :upload, url: "/storage/:class/:id/:basename.:extension"
validates_attachment :u... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | app/controllers/courses_controller.rb | Ruby | mit | 19 | master | 4,682 | class CoursesController < ApplicationController
before_action :set_course, only: [:show, :edit, :update, :destroy, :upload, :do_upload, :resume_upload, :update_status, :reset_upload]
# GET /courses
# GET /courses.json
def index
@courses = Course.all.order(name: :asc)
end
# GET /courses/1
# GET /cour... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | db/schema.rb | Ruby | mit | 19 | master | 1,521 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | db/migrate/20160123005555_create_courses.rb | Ruby | mit | 19 | master | 305 | class CreateCourses < ActiveRecord::Migration
def change
create_table :courses do |t|
t.string :name, null: false
t.string :status, null: false, index: true
t.attachment :upload
t.boolean :visible, default: false, null: false
t.timestamps null: false
end
end
end |
github | cl0w5/rails-resumable-jquery-fileupload | https://github.com/cl0w5/rails-resumable-jquery-fileupload | test/controllers/courses_controller_test.rb | Ruby | mit | 19 | master | 993 | require 'test_helper'
class CoursesControllerTest < ActionController::TestCase
setup do
@course = courses(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:courses)
end
test "should get new" do
get :new
assert_response :success
end
... |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | chain.gemspec | Ruby | mit | 19 | master | 1,101 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'chain/version'
Gem::Specification.new do |spec|
spec.name = "chain"
spec.version = Chain::VERSION
spec.authors = ["Stefan Novak"]
spec.email = ["stefan.louis.... |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | lib/chain.rb | Ruby | mit | 19 | master | 238 | require "uri"
require "json"
require "faraday"
require "hashie"
require "chain/url"
require "chain/version"
require "chain/middleware/hashie_mash_response"
require "chain/middleware/parse_error"
require "chain/middleware/request_error" |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | lib/chain/url.rb | Ruby | mit | 19 | master | 3,199 | module Chain
class Url
attr_accessor :connection, :default_parameters
def initialize(url, base_url=nil, params={}, &block)
@url = url
# Shift method arguments
if base_url.is_a? Hash
base_url, params = nil, base_url
end
@base_url = base_url
@default_parameters = ... |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | lib/chain/middleware/request_error.rb | Ruby | mit | 19 | master | 248 | module Chain
module Middleware
class RequestError < StandardError
attr_reader :error_code
def initialize(error_code)
@error_code = error_code
super("HTTP Response Code: #{error_code}")
end
end
end
end |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | lib/chain/middleware/hashie_mash_response.rb | Ruby | mit | 19 | master | 936 | module Chain
module Middleware
class HashieMashResponse < Faraday::Response::Middleware
def on_complete(env)
case env[:status]
when 200
body = env[:body]
json = JSON.parse(body)
headers = env[:response_headers]
env[:body] = Hashie::Mash.new(json... |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | spec/url_spec.rb | Ruby | mit | 19 | master | 4,765 | require 'spec_helper'
describe Chain::Url do
context 'with HashieMashMiddleware' do
subject do
described_class.new('http://test.com')
end
describe 'response payloads' do
before :each do
body = {data: true}.to_json
stub_request(:get, 'http://test.com/item').
to_r... |
github | stefan-pdx/chain | https://github.com/stefan-pdx/chain | spec/middleware/hasie_mash_response_spec.rb | Ruby | mit | 19 | master | 1,022 | require 'spec_helper'
describe Chain::Middleware::HashieMashResponse do
subject do
described_class.new
end
describe '#on_complete' do
context 'a valid response response with a 200 status' do
let(:env){{body: {success: true}.to_json, status: 200}}
it 'should yield a Hashie::Mash object fro... |
github | AndrewVos/metherd-missing | https://github.com/AndrewVos/metherd-missing | metherd-missing.gemspec | Ruby | mit | 19 | master | 833 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'metherd-missing/version'
Gem::Specification.new do |gem|
gem.name = "metherd-missing"
gem.version = MetherdMissing::VERSION
gem.authors = ["Andrew Vos"]
gem... |
github | AndrewVos/metherd-missing | https://github.com/AndrewVos/metherd-missing | lib/metherd-missing.rb | Ruby | mit | 19 | master | 597 | require "metherd-missing/version"
require "metherd-missing/levenshtein_distance"
require "metherd-missing/trie_node"
module Kernel
def method_missing(method, *args, &block)
possible_method_names = self.methods.map(&:to_s)
results = MetherdMissing::LevenshteinDistance.new(possible_method_names).search(method,... |
github | AndrewVos/metherd-missing | https://github.com/AndrewVos/metherd-missing | lib/metherd-missing/levenshtein_distance.rb | Ruby | mit | 19 | master | 1,434 | module MetherdMissing
class LevenshteinDistance
def initialize(words)
@trie = TrieNode.new
words.each do |word|
@trie.insert(word)
end
end
def search word, maximum_distance
current_row = (0..word.length).to_a
results = {}
@trie.children.keys.each do |letter|
... |
github | AndrewVos/metherd-missing | https://github.com/AndrewVos/metherd-missing | lib/metherd-missing/trie_node.rb | Ruby | mit | 19 | master | 379 | module MetherdMissing
class TrieNode
attr_accessor :word, :children
def initialize
@children = {}
end
def insert word
node = self
word.each_char do |letter|
unless node.children[letter]
node.children[letter] = TrieNode.new
end
node = node.children[... |
github | gussan/rubygems-socksproxy | https://github.com/gussan/rubygems-socksproxy | rubygems-socksproxy.gemspec | Ruby | mit | 19 | master | 965 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rubygems/socksproxy/version'
Gem::Specification.new do |spec|
spec.name = "rubygems-socksproxy"
spec.version = Rubygems::Socksproxy::VERSION
spec.authors = ["gussan"]
... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | swfobject-rails.gemspec | Ruby | mit | 19 | master | 1,035 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "swfobject/rails/version"
Gem::Specification.new do |s|
s.name = "swfobject-rails"
s.version = Swfobject::Rails::VERSION
s.authors = ["Corin Langosch"]
s.email = ["info@corinlangosch.com"]
s.homepage = "htt... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/spec_helper.rb | Ruby | mit | 19 | master | 431 | # Configure Rails Envinronment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rspec/rails"
require "nokogiri"
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.r... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/dummy/config/application.rb | Ruby | mit | 19 | master | 1,828 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "rails/all"
Bundler.require
require "swfobject-rails"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 19 | master | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/helpers/swfobject_helper_spec.rb | Ruby | mit | 19 | master | 5,224 | require "spec_helper"
describe SwfobjectHelper do
describe "#swf_tag" do
it "returns with static embedingd HTML" do
output = helper.swf_tag "myContent"
doc = Nokogiri::HTML(output)
object = doc.at_css "body > object"
object["id"].should == "my_content"
object["name"].should ... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/support/be_content_type_matcher.rb | Ruby | mit | 19 | master | 272 | RSpec::Matchers.define :be_content_type do |expected|
match do |actual|
actual.respond_to?(:content_type) && actual.content_type == expected
end
failure_message_for_should do |actual|
"expected #{actual.try(:content_type)} to equal #{expected}"
end
end |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | spec/requests/assets_spec.rb | Ruby | mit | 19 | master | 818 | require "spec_helper"
describe "SWFObject Assets" do
describe "GET swfobject.js" do
before { get "/assets/swfobject-full.js" }
subject { response }
it { should be_ok }
it { should be_content_type("text/javascript") }
it { should have_content("var swfobject = function() {") }
end... |
github | gucki/swfobject-rails | https://github.com/gucki/swfobject-rails | app/helpers/swfobject_helper.rb | Ruby | mit | 19 | master | 3,270 | module SwfobjectHelper
# Default options for the #swfobject helper.
DEFAULT_OPTIONS = {
:width => "100%",
:height => "100%",
:version => "9.0.0",
:partial => "shared/swfobject"
}
# Default <param> tags.
DEFAULT_PARAMS = {
:allowfullscreen => true,
:allowscriptaccess => "always",
... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | current_me.gemspec | Ruby | mit | 19 | master | 796 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/current_me/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["Tagaki Aki"]
gem.email = ["aki.hosecarioka@gmail.com"]
gem.description = %q{possess a current user}
gem.summary = %q{CurrentMe possesses a current user... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/Gemfile | Ruby | mit | 19 | master | 873 | source 'https://rubygems.org'
gem 'rails', '3.2.15'
gem 'current_me', path: '../../../current_me'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-r... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/app/controllers/users_controller.rb | Ruby | mit | 19 | master | 296 | class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
end
def create
@user = User.new(params[:user])
if @user.save
self.me = @user
redirect_to @user
else
render 'new'
end
end
end |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/app/controllers/sessions_controller.rb | Ruby | mit | 19 | master | 323 | class SessionsController < ApplicationController
def new
end
def create
origin = session[:origin]
user = User.find_by_name(params[:name])
if user
sign_in user
redirect_to origin || user
else
render 'new'
end
end
def destroy
sign_out
redirect_to root_path
end
e... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/db/schema.rb | Ruby | mit | 19 | master | 962 | # encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative sou... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/config/application.rb | Ruby | mit | 19 | master | 2,810 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.requi... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/config/initializers/secret_token.rb | Ruby | mit | 19 | master | 496 | # Be sure to restart your server when you modify this file.
# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attac... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/spec/spec_helper.rb | Ruby | mit | 19 | master | 1,199 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirect... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/spec/controllers/sessions_controller_spec.rb | Ruby | mit | 19 | master | 454 | # coding: utf-8
require 'spec_helper'
describe SessionsController do
let!(:user) { User.create!(name: 'akiinyo') }
describe 'destroy' do
before {
controller.sign_in user
delete :destroy, {id: user.id}
}
specify 'meがいなくなること' do
controller.me?.should be_false
end
specify 'トップ... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/spec/controllers/users_controller_spec.rb | Ruby | mit | 19 | master | 333 | # coding: utf-8
require 'spec_helper'
describe UsersController do
let(:user) { User.create!(name: 'akiinyo') }
describe 'me' do
before {
post :create, user: {id: user.id, name: user.name}
}
specify 'meが正しく設定されていること' do
controller.me.name.should == 'akiinyo'
end
end
end |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | spec/dummy/spec/controllers/rooms_controller_spec.rb | Ruby | mit | 19 | master | 493 | # coding: utf-8
require 'spec_helper'
describe RoomsController do
describe 'me!' do
let!(:user) { User.create!(name: 'akiinyo') }
subject &:response
context 'ログインしている場合' do
before {
controller.sign_in user
get :index
}
it { should render_template('index') }
end
... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | lib/current_me.rb | Ruby | mit | 19 | master | 617 | require "current_me/version"
require File.join(File.dirname(__FILE__), 'current_me', 'railtie') if defined?(Rails::Railtie)
module CurrentMe
extend ActiveSupport::Concern
included do
helper_method :me, :me?
end
def me
if id = session[:me]
@me ||= User.find(id)
end
rescue ActiveRecord::Rec... |
github | akiinyo/current_me | https://github.com/akiinyo/current_me | lib/current_me/railtie.rb | Ruby | mit | 19 | master | 225 | module CurrentMe
class Railtie < ::Rails::Railtie
initializer 'CurrentMe' do |app|
ActiveSupport.on_load :action_controller do
::ActionController::Base.send :include, CurrentMe
end
end
end
end |
github | sky-y/xmorgdown | https://github.com/sky-y/xmorgdown | parser.rb | Ruby | mit | 19 | master | 1,323 | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Add current path to load path
# https://github.com/komagata/lokka/blob/master/init.rb
$:.unshift File.dirname(__FILE__)
require 'pp'
require 'zipruby'
require 'nokogiri'
SRC_DIR = File.dirname(__FILE__)
module XMorgDown
class Parser
attr_accessor :file_xmind
... |
github | sky-y/xmorgdown | https://github.com/sky-y/xmorgdown | exporter.rb | Ruby | mit | 19 | master | 1,892 | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'pp'
require 'open3'
module XMorgDown
# Export a HTML to any filetypes with Pandoc
# Original Source: pandoc-ruby
# https://github.com/alphabetum/pandoc-ruby/blob/master/lib/pandoc-ruby.rb
class Exporter
attr_reader :result
attr_accessor :html
... |
github | sky-y/xmorgdown | https://github.com/sky-y/xmorgdown | test_XMorgDown.rb | Ruby | mit | 19 | master | 221 | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require 'test/unit'
require 'pp'
require './XMorgDown.rb'
class TestCommand < Test::Unit::TestCase
def setup
end
def test_commands()
end
end |
github | sky-y/xmorgdown | https://github.com/sky-y/xmorgdown | XMorgDown.rb | Ruby | mit | 19 | master | 4,263 | #!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "optparse"
require 'pp'
module XMorgDown
DEBUG = false
end
# Add current path to load path
# https://github.com/komagata/lokka/blob/master/init.rb
$:.unshift File.dirname(__FILE__)
# Set the current directory to this directory
#Dir.chdir(File.dirname(__FILE__))
... |
github | securityroots/passdb | https://github.com/securityroots/passdb | Rakefile | Ruby | mit | 19 | master | 545 | # encoding: utf-8
require File.expand_path('../lib/passdb/version', __FILE__)
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
require 'rdoc/task'
if defined?(RDoc)
RDoc::Task.new do |rdoc|
rdoc.main = 'README.md'
rdoc.rdoc_dir = 'rdoc'... |
github | securityroots/passdb | https://github.com/securityroots/passdb | passdb.gemspec | Ruby | mit | 19 | master | 2,438 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/passdb/version', __FILE__)
extra_rdoc_files = ['LICENSE.txt', 'README.md', 'Rakefile']
Gem::Specification.new do |s|
s.name = %q{passdb}
s.version = Passdb::VERSION::STRING.dup
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to?... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.