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 | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/lxd.rb | Ruby | mit | 19 | master | 1,063 | # frozen_string_literal: true
# require 'singleton'
# require 'fileutils'
# require 'shellwords'
# require 'sfl' if Specinfra.ruby_is_older_than?(1, 9, 0)
module Specinfra
module Backend
# LXD transport
class Lxd < Exec
def build_command(cmd)
lxc_cmd = %W[lxc exec #{instance}]
lxc_cmd ... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/telnet.rb | Ruby | mit | 19 | master | 2,618 | # -*- coding: utf-8 -*-
# require 'specinfra/backend/exec'
# require 'net/telnet'
module Specinfra
module Backend
class Telnet < Exec
def run_command(cmd, opt={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
ret = with_env do
telnet_exec!(cmd)
end
if... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/ssh.rb | Ruby | mit | 19 | master | 5,303 | # -*- coding: utf-8 -*-
# require 'specinfra/backend/exec'
# require 'net/ssh'
# require 'net/scp'
module Specinfra
module Backend
class Ssh < Exec
def run_command(cmd, opt={})
cmd = build_command(cmd)
cmd = add_pre_command(cmd)
if get_config(:ssh_without_env)
ret = ssh_e... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/cmd.rb | Ruby | mit | 19 | master | 2,375 | # require 'open3'
module Specinfra
module Backend
class Cmd < Base
include PowerShell::ScriptHelper
def os_info
{ :family => 'windows', :release => nil, :arch => nil, :cygwin => `echo $0`.include?("sh") }
end
def run_command(cmd, opts={})
script = create_script(cmd)
... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/shell_script.rb | Ruby | mit | 19 | master | 514 | # require 'singleton'
module Specinfra
module Backend
class ShellScript < Base
def initialize(config = {})
super
@lines = [ "#!/bin/sh", "" ]
ObjectSpace.define_finalizer(self, Writer.new(@lines))
end
def run_command(cmd, opts={})
@lines << cmd
CommandR... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/backend/2_powershell/script_helper.rb | Ruby | mit | 19 | master | 2,155 | # require 'base64'
module Specinfra
module Backend
module PowerShell
module ScriptHelper
def build_command(cmd)
path = get_config(:path)
if path
cmd.strip!
cmd =
<<-EOF
$env:path = "#{path};$env:path"
#{cmd}
EOF
end
cmd
end
... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/host_inventory/ohai.rb | Ruby | mit | 19 | master | 467 | module Specinfra
class HostInventory
class Ohai < Base
def get
begin
# require 'json'
raise 'mruby-specinfra does not support dynamic require'
rescue StandardError
return nil
end
begin
ret = backend.run_command('ohai --log_level error'... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/host_inventory/facter.rb | Ruby | mit | 19 | master | 320 | module Specinfra
class HostInventory
class Facter < Base
# require 'yaml'
def get
begin
ret = backend.run_command('facter --puppet --yaml')
rescue StandardError
nil
end
ret.exit_status == 0 ? YAML.load(ret.stdout) : nil
end
end
end
end |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/docker.rb | Ruby | mit | 19 | master | 358 | module Specinfra
module Helper
module Docker
def self.included(klass)
# require 'docker' unless Object.const_defined?("::Docker")
raise 'mruby-specinfra does not support dynamic require'
rescue StandardError
fail "Docker client library is not available. Try installing `docker-a... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/configuration.rb | Ruby | mit | 19 | master | 1,407 | module Specinfra
module Helper
module Configuration
def subject
example = RSpec.respond_to?(:current_example) ? RSpec.current_example : self.example
example.metadata[:subject] = described_class
build_configurations
super
end
# You can create a set of configuratio... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/os.rb | Ruby | mit | 19 | master | 256 | # require 'specinfra/helper/detect_os'
module Specinfra
module Helper
module Os
def os
property[:os] = Specinfra.configuration.os ?
Specinfra.configuration.os :
Specinfra.backend.os_info
end
end
end
end |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/lxc.rb | Ruby | mit | 19 | master | 357 | module Specinfra
module Helper
module Lxc
def self.included(klass)
# require 'lxc/extra' unless Object.const_defined?("::LXC::Extra")
raise 'mruby-specinfra does not support dynamic require'
rescue StandardError
fail "LXC client library is not available. Try installing `ruby-lx... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/detect_os.rb | Ruby | mit | 19 | master | 1,306 | module Specinfra
module Helper
class DetectOs
def self.detect
self.new(Specinfra.backend).detect
end
def initialize(backend)
@backend = backend
end
def run_command(cmd)
@backend.run_command(cmd)
end
def detect
raise NotImplementedError
... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/properties.rb | Ruby | mit | 19 | master | 281 | # require 'specinfra/properties'
module Specinfra
module Helper
module Properties
def property
Specinfra::Properties.instance.properties
end
def set_property(prop)
Specinfra::Properties.instance.properties(prop)
end
end
end
end |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | mrblib/specinfra/helper/detect_os/suse.rb | Ruby | mit | 19 | master | 963 | class Specinfra::Helper::DetectOs::Suse < Specinfra::Helper::DetectOs
def detect
if run_command('ls /etc/os-release').success? and run_command('zypper -V').success?
line = run_command('cat /etc/os-release').stdout
if line =~ /ID="?opensuse/
family = 'opensuse'
elsif line =~ /ID="sles"/
... |
github | itamae-kitchen/mruby-specinfra | https://github.com/itamae-kitchen/mruby-specinfra | test/specinfra.rb | Ruby | mit | 19 | master | 564 | assert('Specinfra host_inventory') do
backend = Specinfra::Backend::Exec.new(shell: '/bin/sh')
assert_kind_of Specinfra::HostInventory, backend.host_inventory
end
assert('Specinfra host_inventory ec2') do
backend = Specinfra::Backend::Exec.new(shell: '/bin/sh')
assert_nil backend.host_inventory["ec2"]["instanc... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms_achievements.rb | Ruby | mit | 19 | master | 2,491 | require 'CSV'
require_relative 'itms_utils.rb'
class ITMSAchievements
def self.locale_string(locale_name, title, before_description, after_description, image_name)
image_data_string = ITMSUtils.image_data_string(@@input_images_dir, image_name)
@@images_used << "#{@@input_images_dir}/#{image_name}"
outp... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms_app_store.rb | Ruby | mit | 19 | master | 2,695 | require 'CSV'
require_relative 'itms_utils.rb'
class ITMSAppStore
def self.description_string(locale_name)
filename = "#{@@locales_directory}/#{locale_name}/app_store_description.txt"
contents = File.open(filename, 'rb').read
contents.force_encoding('UTF-8')
contents
end
def self.keywords(raw_i... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms_leaderboards.rb | Ruby | mit | 19 | master | 2,308 | require 'CSV'
require_relative 'itms_utils.rb'
class ITMSLeaderboards
def self.locale_string(locale_name, title, formatter_type, image_name)
image_data_string = ITMSUtils.image_data_string(@@input_images_dir, image_name)
@@images_used << "#{@@input_images_dir}/#{image_name}"
output = "<locale name=\"#{... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms_utils.rb | Ruby | mit | 19 | master | 3,354 | require 'digest'
require 'set'
TRANSPORTER_CMD = 'xcrun iTMSTransporter'
class ITMSUtils
def self.download_metadata(username, password, app_id, destination, log_name)
cmd = "#{TRANSPORTER_CMD} -m lookupMetadata -u #{username} -p \"#{password}\" -apple_id #{app_id} -destination #{destination} &> #{log_name}"
... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms_iap.rb | Ruby | mit | 19 | master | 2,420 | require 'CSV'
require_relative 'itms_utils.rb'
class ITMSIAP
def self.locale_string(locale_name, title, description)
output = "<locale name=\"#{locale_name}\">"
output += "<title>#{title}</title>"
output += "<description>#{description}</description>"
output += "</locale>"
output
end
def sel... |
github | raresloth/itms-scripts | https://github.com/raresloth/itms-scripts | itms.rb | Ruby | mit | 19 | master | 3,954 | #!/usr/bin/env ruby
require 'set'
require 'JSON'
require_relative 'itms_utils.rb'
require_relative 'itms_app_store.rb'
require_relative 'itms_iap.rb'
require_relative 'itms_achievements.rb'
require_relative 'itms_leaderboards.rb'
config_filename = 'itms.config'
if ARGV.include? '-c'
config_filename_index = ARGV.in... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | metadata.rb | Ruby | apache-2.0 | 19 | master | 516 | name 'cloudcli'
maintainer 'Christopher Licata'
maintainer_email 'cmlpolyglotdev@gmail.com'
license 'Apache 2.0'
description 'Install and configure cloud provider CLI tools.'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '1.3.0'
source_url 'https://github.com/cmlicata/cloudcli-cookboo... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | Gemfile | Ruby | apache-2.0 | 19 | master | 260 | source 'https://rubygems.org'
gem 'berkshelf'
gem 'emeril'
group :style do
gem 'foodcritic'
gem 'rubocop'
end
group :test do
gem 'chefspec'
gem 'kitchen-docker'
gem 'kitchen-vagrant'
gem 'test-kitchen'
end
group :aws do
gem 'kitchen-ec2'
end |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | Rakefile | Ruby | apache-2.0 | 19 | master | 680 | # -*- mode: ruby -*-
# vi: set ft=ruby :
require 'bundler/setup'
require 'emeril/rake'
namespace :style do
require 'rubocop/rake_task'
desc 'Run rubocop for Ruby style checks'
RuboCop::RakeTask.new(:ruby)
require 'foodcritic'
desc 'Run foodcritic for Chef style checks'
FoodCritic::Rake::LintTask.new(:chef... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | Berksfile | Ruby | apache-2.0 | 19 | master | 396 | source "https://supermarket.chef.io"
metadata
group :integration do
cookbook "apt"
cookbook "yum"
cookbook 'node_dump', path: 'test/fixtures/cookbooks/node_dump'
cookbook 'test_get', path: 'test/fixtures/cookbooks/test_get'
cookbook 'test_virtualenv', path: 'test/fixtures/cookbooks/test_virtualenv'
cookbo... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | resources/aws_credentials.rb | Ruby | apache-2.0 | 19 | master | 957 | #
# Cookbook Name:: cloudcli
# Resources:: config
#
# Copyright (C) 2016 Nick Downs
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | resources/aws_s3_file.rb | Ruby | apache-2.0 | 19 | master | 1,415 | #
# Cookbook Name:: cloudcli
# Resources:: aws_s3_file
#
# Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | attributes/default.rb | Ruby | apache-2.0 | 19 | master | 1,253 | #
# Cookbook Name:: cloudcli
# Attributes:: default
#
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | spec/unit/spec_helper.rb | Ruby | apache-2.0 | 19 | master | 615 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | spec/unit/recipes/_aws_windows_spec.rb | Ruby | apache-2.0 | 19 | master | 1,350 | # Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# ... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | spec/unit/recipes/awscli_spec.rb | Ruby | apache-2.0 | 19 | master | 1,310 | # Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# ... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | spec/unit/recipes/_aws_linux_spec.rb | Ruby | apache-2.0 | 19 | master | 1,747 | # Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# ... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | recipes/_aws_linux.rb | Ruby | apache-2.0 | 19 | master | 1,181 | #
# Cookbook Name:: cloudcli
# Recipe:: _aws_linux
#
# Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is loc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | recipes/awscli.rb | Ruby | apache-2.0 | 19 | master | 751 | #
# Cookbook Name:: cloudcli
# Recipe:: awscli
#
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazo... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | recipes/default.rb | Ruby | apache-2.0 | 19 | master | 651 | #
# Cookbook Name:: cloudcli
# Recipe:: default
#
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amaz... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | recipes/_aws_windows.rb | Ruby | apache-2.0 | 19 | master | 889 | #
# Cookbook Name:: cloudcli
# Recipe:: _aws_windows
#
# Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is l... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | providers/aws_s3_file.rb | Ruby | apache-2.0 | 19 | master | 3,112 | #
# Cookbook Name:: cloudcli
# provider:: aws_s3_file
#
# Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is ... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | providers/aws_credentials.rb | Ruby | apache-2.0 | 19 | master | 2,143 | #
# Cookbook Name:: cloudcli
# provider:: aws_credentials
#
# Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/integration/test_get/serverspec/test_get_spec.rb | Ruby | apache-2.0 | 19 | master | 1,386 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/integration/test_virtualenv/serverspec/test_virtualenv_spec.rb | Ruby | apache-2.0 | 19 | master | 720 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/integration/test_credentials/serverspec/test_credentials_spec.rb | Ruby | apache-2.0 | 19 | master | 1,367 | # Copyright 2016 Nick Downs
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is
# distribute... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/integration/profile_test_get/serverspec/test_get_spec.rb | Ruby | apache-2.0 | 19 | master | 820 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/integration/default/serverspec/default_spec.rb | Ruby | apache-2.0 | 19 | master | 828 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | test/shared/spec_helper.rb | Ruby | apache-2.0 | 19 | master | 665 | # Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file acc... |
github | cmlicata/cloudcli-cookbook | https://github.com/cmlicata/cloudcli-cookbook | libraries/matchers.rb | Ruby | apache-2.0 | 19 | master | 1,017 | # Copyright 2016 Nick Downs
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# ... |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | Rakefile | Ruby | mit | 19 | master | 560 | # encoding: utf-8
require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
warn e.message
warn "Run `gem install bundler` to install Bundler."
exit -1
end
begin
Bundler.setup(:development)
rescue Bundler::BundlerError => e
warn e.message
warn "Run `bundle install` to install missing gems."
ex... |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | taiwanese_ubn_validator.gemspec | Ruby | mit | 19 | master | 914 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/taiwanese_ubn_validator/version', __FILE__)
Gem::Specification.new do |gem|
gem.name = 'taiwanese_ubn_validator'
gem.version = TaiwaneseUbnValidator::VERSION
gem.summary = %q{台灣/中華民國之統一編號的檢查驗證}
gem.description = gem.summary
ge... |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | lib/taiwanese_ubn_validator.rb | Ruby | mit | 19 | master | 831 | require 'taiwanese_ubn_validator/version'
module TaiwaneseUbnValidator
MULTIPLIER = [1,2,1,2,1,2,4,1].freeze
# @ubn - 8 digits string
def self.valid?(ubn)
ubn = ubn.to_s
return false if ubn.length != 8
return false if !( ubn =~ /^\d+$/ )
digits = ubn.chars.map(&:to_i)
special_sum = calcul... |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | lib/taiwanese_ubn_validator/rails_validator.rb | Ruby | mit | 19 | master | 290 | # encoding: utf-8
module TaiwaneseUbnValidator
class RailsValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
if !TaiwaneseUbnValidator.valid?(value)
record.errors[attribute] << (options[:message] || "有誤")
end
end
end
end |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | spec/validate_taiwanese_ubn_spec.rb | Ruby | mit | 19 | master | 2,023 | require 'helper'
require 'taiwanese_ubn_validator'
describe TaiwaneseUbnValidator do
it 'has version' do
TaiwaneseUbnValidator.const_get('VERSION').wont_be_empty
end
it 'reject incorrect ubn' do
TaiwaneseUbnValidator.valid?('73251200').must_equal false
TaiwaneseUbnValidator.valid?('18556773').must_... |
github | GoodLife/taiwanese_ubn_validator | https://github.com/GoodLife/taiwanese_ubn_validator | spec/helper.rb | Ruby | mit | 19 | master | 431 | require 'rubygems'
begin
require 'bundler'
rescue LoadError => e
STDERR.puts e.message
STDERR.puts "Run `gem install bundler` to install Bundler."
exit e.status_code
end
begin
Bundler.setup(:default, :development, :test)
rescue Bundler::BundlerError => e
STDERR.puts e.message
STDERR.puts "Run `bundle in... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | Rakefile | Ruby | mit | 19 | master | 2,325 | #!/usr/bin/env rake
require "bundler/gem_tasks"
require 'rake/testtask'
require './test/supports'
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*_test.rb']
t.verbose = true
end
desc "sync bootstrap-sass"
task :sync do
if File.exists? "tmp/bootstrap-sass"
`cd tmp/bootstrap-sass &... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | todc-bootstrap-sass.gemspec | Ruby | mit | 19 | master | 939 | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/todc-bootstrap-sass/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["ichord"]
gem.email = ["chord.luo@gmail.com"]
gem.description = %q{google-bootstrap in sass for rails}
gem.summary = %q{google style for bootst... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | lib/todc-bootstrap-sass.rb | Ruby | mit | 19 | master | 1,355 | require "todc-bootstrap-sass/version"
module Todc
module Bootstrap
module Sass
class FrameworkNotFound < StandardError; end
def self.load!
if compass? && asset_pipeline?
register_compass_extension
register_rails_engine
elsif compass?
# Only require compass extension ... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | lib/todc-bootstrap-sass/rails_functions.rb | Ruby | mit | 19 | master | 484 | require 'sass'
module Sass::Script::Functions
# LARS: Snatched from compass - 2011-11-29 - used for gradients in IE6-9
# returns an IE hex string for a color with an alpha channel
# suitable for passing to IE filters.
def ie_hex_str(color)
assert_type color, :Color
alpha = (color.alpha * 255).round
... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | lib/todc-bootstrap-sass/compass_functions.rb | Ruby | mit | 19 | master | 500 | # This contains functions for use with a project *only* using Compass.
module Sass::Script::Functions
# Define image_path for Compass to allow use of sprites without url() wrapper.
def image_path(asset)
if defined?(::Compass)
image_url(asset, Sass::Script::Bool.new(true))
else
# Revert to the o... |
github | ichord/todc-bootstrap-sass | https://github.com/ichord/todc-bootstrap-sass | test/supports.rb | Ruby | mit | 19 | master | 570 | $:.unshift("#{File.dirname(__FILE__)}/..")
require 'sass'
require 'lib/todc-bootstrap-sass/compass_functions'
require 'lib/todc-bootstrap-sass/rails_functions'
def sass_engine
path = 'lib/assets/stylesheets'
bootstrap_sass_path = "tmp/bootstrap-sass/vendor/assets/stylesheets"
content = <<-END
@import "bootstr... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | multiple_man.gemspec | Ruby | mit | 19 | master | 1,198 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'multiple_man/version'
Gem::Specification.new do |spec|
spec.name = "multiple_man"
spec.version = MultipleMan::VERSION
spec.authors = ["Ryan Brunner"]
spec.email ... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man.rb | Ruby | mit | 19 | master | 1,713 | require "multiple_man/version"
require 'active_support'
module MultipleMan
Error = Class.new(StandardError)
ConsumerError = Class.new(Error)
ProducerError = Class.new(Error)
ConnectionError = Class.new(Error)
require 'multiple_man/railtie' if defined?(Rails)
require 'multiple_man/mixins/publisher'
requ... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/runner.rb | Ruby | mit | 19 | master | 1,881 | require 'forwardable'
module MultipleMan
class Runner
class ShutDown < Error; end
extend Forwardable
MODES = [:general, :seed].freeze
def initialize(options = {})
@mode = options.fetch(:mode, :general)
raise ArgumentError, "undefined mode: #{mode}" unless MODES.include?(mode)
end
... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/routing_key.rb | Ruby | mit | 19 | master | 691 | module MultipleMan
class RoutingKey
ALLOWED_OPERATIONS = [:create, :update, :destroy, :seed, :"#"]
def initialize(klass, operation = :"#")
self.klass = klass
self.operation = operation
end
def to_s
if operation.to_sym == :seed
"#{topic_name}.#{operation}.#{klass}"
els... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/connection.rb | Ruby | mit | 19 | master | 2,885 | require 'bunny'
require 'active_support/core_ext/module'
module MultipleMan
class Connection
@mutex = Mutex.new
def self.connect
yield new(channel)
Thread.current[:multiple_man_exception_retry_count] = 0
rescue Bunny::Exception, Timeout::Error => e
recovery_options = MultipleMan.config... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/payload_generator.rb | Ruby | mit | 19 | master | 756 | module MultipleMan
class PayloadGenerator
def initialize(record, operation = :create, options = {})
self.record = record
self.operation = operation.to_s
self.options = options
end
def payload
{
type: type,
operation: operation,
id: id,
data: data
... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/model_populator.rb | Ruby | mit | 19 | master | 1,026 | module MultipleMan
class ModelPopulator
def initialize(record, fields)
self.record = record
self.fields = fields
end
def populate(payload)
data = payload[:id].merge(payload[:data])
fields_for(data).each do |field|
source, dest = field.is_a?(Array) ? field : [field, field]... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/attribute_extractor.rb | Ruby | mit | 19 | master | 776 | require 'json'
module MultipleMan
class AttributeExtractor
def initialize(record, fields, include_previous = false)
raise "Fields must be specified" unless fields
self.include_previous = include_previous
self.record = record
self.fields = fields
end
def as_json
if include... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/configuration.rb | Ruby | mit | 19 | master | 1,562 | module MultipleMan
def self.configuration
@configuration ||= Configuration.new
end
def self.configure
yield(configuration) if block_given?
end
class Configuration
attr_reader :subscriber_registry
attr_accessor :topic_name, :app_name, :connection, :enabled, :error_handler,
:... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/cli.rb | Ruby | mit | 19 | master | 842 | require 'optparse'
module MultipleMan
class Options < OptionParser
def self.parse!(args)
parser = new('Multiple Man')
parser.set_opts.parse!(args)
parser.options
end
attr_reader :options
def initialize(*args)
@options = { mode: :general, environment_path: 'config/environment... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/identity.rb | Ruby | mit | 19 | master | 1,156 | module MultipleMan
class Identity
def self.build(record, options)
if options[:identifier].present?
SingleField.new(record, options[:identifier])
else
MultipleField.new(record, options[:identify_by])
end
end
def initialize(record)
self.record = record
end
a... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/railtie.rb | Ruby | mit | 19 | master | 203 | require 'multiple_man'
require 'rails'
module MultipleMan
class Railtie < Rails::Railtie
railtie_name :multiple_man
rake_tasks do
load "multiple_man/tasks/worker.rake"
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/model_publisher.rb | Ruby | mit | 19 | master | 1,426 | require 'active_support/core_ext'
module MultipleMan
class ModelPublisher
def initialize(options = {})
self.options = options.with_indifferent_access
end
def publish(records, operation=:create)
return unless MultipleMan.configuration.enabled
Connection.connect do |connection|
... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/tasks/worker.rake | Ruby | mit | 19 | master | 265 | namespace :multiple_man do
desc 'Run multiple man listeners'
task worker: :environment do
MultipleMan::Runner.new(mode: :general).run
end
desc 'Run a seeding listener'
task seed: :environment do
MultipleMan::Runner.new(mode: :seed).run
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/channel_maintenance/gc.rb | Ruby | mit | 19 | master | 2,418 | module MultipleMan
module ChannelMaintenance
class GC
def self.finalizer(thread_id, channel, queue, reaper)
proc { queue << RemoveCommand.new(thread_id); reaper.push(channel) }
end
def initialize(_, reaper)
@reaper = reaper
@queue = Queue.new
@executor = Thread.... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/channel_maintenance/reaper.rb | Ruby | mit | 19 | master | 748 | module MultipleMan
module ChannelMaintenance
class Reaper
def initialize(config)
@config = config
@queue = Queue.new
@worker = Thread.new do
loop do
channel = queue.pop
begin
channel.close unless channel.closed?
puts "Cha... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/mixins/listener.rb | Ruby | mit | 19 | master | 693 | module MultipleMan
module Listener
def self.included(base)
base.extend(ClassMethods)
end
def routing_key(operation = self.operation)
MultipleMan::RoutingKey.new(listen_to, operation).to_s
end
attr_accessor :operation
attr_accessor :listen_to
def create(payload)
# noop
... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/mixins/publisher.rb | Ruby | mit | 19 | master | 990 | require 'active_support/core_ext'
module MultipleMan
module Publisher
def Publisher.included(base)
base.extend(ClassMethods)
if base.respond_to?(:after_commit)
base.after_commit(on: :create) { |r| r.multiple_man_publish(:create) }
base.after_commit(on: :update) do |r|
if !r.... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/mixins/subscriber.rb | Ruby | mit | 19 | master | 303 | module MultipleMan
module Subscriber
def Subscriber.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def subscribe(options = {})
::MultipleMan.configuration.register_listener(Subscribers::ModelSubscriber.new(self, options))
end
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/subscribers/model_subscriber.rb | Ruby | mit | 19 | master | 1,103 | module MultipleMan::Subscribers
class ModelSubscriber < Base
def initialize(klass, options)
self.model_class = klass
super(options[:to] || klass.name)
self.options = options
end
attr_accessor :options
def create(payload)
id = payload[:id]
model = find_model(id)
M... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/subscribers/registry.rb | Ruby | mit | 19 | master | 225 | module MultipleMan::Subscribers
class Registry
attr_reader :subscriptions
def initialize
@subscriptions = []
end
def register(subscription)
self.subscriptions << subscription
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/subscribers/base.rb | Ruby | mit | 19 | master | 478 | module MultipleMan::Subscribers
class Base
def initialize(klass)
self.klass = klass
end
attr_reader :klass
def create(_)
# noop
end
def update(_)
# noop
end
def destroy(_)
# noop
end
def seed(_)
# noop
end
def routing_key(operation =... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/consumers/general.rb | Ruby | mit | 19 | master | 2,510 | require 'json'
require 'active_support/core_ext/hash'
module MultipleMan
module Consumers
class General
def initialize(subscribers:, queue:, topic:)
self.subscribers = subscribers
@topic = topic
@queue = queue
end
def listen
MultipleMan.logger.debug "Starting li... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/consumers/seed.rb | Ruby | mit | 19 | master | 217 | module MultipleMan::Consumers
class Seed < General
private
def operation(_, _)
"create"
end
def routing_key_for_subscriber(subscriber)
subscriber.routing_key(:seed)
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | lib/multiple_man/tracers/null_tracer.rb | Ruby | mit | 19 | master | 264 | module MultipleMan
module Tracers
class NullTracer
def initialize(subscriber)
@subscriber = subscriber
end
def handle(delivery_info, meta_data, message, method)
@subscriber.send(method, message)
end
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/model_publisher_spec.rb | Ruby | mit | 19 | master | 2,036 | require 'spec_helper'
describe MultipleMan::ModelPublisher do
let(:channel_stub) { double(Bunny::Channel, topic: topic_stub)}
let(:topic_stub) { double(Bunny::Exchange, publish: nil) }
before {
MultipleMan::Connection.stub(:connect).and_yield(channel_stub)
MultipleMan.configure do |config|
config.... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/connection_spec.rb | Ruby | mit | 19 | master | 802 | require 'spec_helper'
describe MultipleMan::Connection do
let(:mock_bunny) { double(Bunny, open?: true, close: nil) }
let(:mock_channel) { double(Bunny::Channel, close: nil, open?: true, topic: nil, number: 1) }
after do
Thread.current.thread_variable_set(:multiple_man_current_channel, nil)
MultipleMan... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/logger_spec.rb | Ruby | mit | 19 | master | 334 | require 'spec_helper'
describe MultipleMan do
let(:mock_logger) { double(Logger) }
before do
MultipleMan.configuration.stub(:logger).and_return(mock_logger)
end
it "should use the logger from configuration" do
mock_logger.should_receive(:info).with("My message")
MultipleMan.logger.info "My messa... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/attribute_extractor_spec.rb | Ruby | mit | 19 | master | 854 | require 'spec_helper'
describe MultipleMan::AttributeExtractor do
MockClass = Struct.new(:a, :b, :c, :id)
let(:object) { MockClass.new(1,2,3,10) }
subject { described_class.new(object, fields, include_previous) }
let(:fields) { nil }
let(:include_previous) { false }
context "without fields" do
it "s... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/model_populator_spec.rb | Ruby | mit | 19 | master | 1,674 | require 'spec_helper'
describe MultipleMan::ModelPopulator do
class MockModel
attr_accessor :a, :b, :multiple_man_identifier
end
describe "populate" do
let(:model) { MockModel.new }
let(:data) { { a: 1, b: 2 } }
let(:id) { { multiple_man_identifier: 'app_1' }}
let(:fields) { nil }
subjec... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/runner_spec.rb | Ruby | mit | 19 | master | 917 | require 'spec_helper'
describe MultipleMan::Runner do
let(:mock_channel) { double("Channel", prefetch: true, queue: true) }
let(:mock_connection) { double("Connection", create_channel: mock_channel) }
let(:mock_consumer) { double("Consumer", listen: true) }
it 'boots app and listens on new channel' do
exp... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/payload_generator_spec.rb | Ruby | mit | 19 | master | 1,655 | require 'spec_helper'
describe MultipleMan::PayloadGenerator do
class PayloadMockClass < Struct.new(:foo, :bar)
end
let(:mock_object) { PayloadMockClass.new(1,2) }
describe "operation" do
it "should be whatever was passed in" do
expect(described_class.new(mock_object, :update).operation).to eq('up... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/routing_key_spec.rb | Ruby | mit | 19 | master | 1,313 | require 'spec_helper'
describe MultipleMan::RoutingKey do
class MockObject
end
before do
MultipleMan.configure do |config|
config.topic_name = "app"
end
end
describe "to_s" do
subject { described_class.new("MockObject", operation).to_s }
context "creating" do
let(:operation) { ... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/identity_spec.rb | Ruby | mit | 19 | master | 1,192 | require 'spec_helper'
describe MultipleMan::Identity do
let(:record) { double(:model, id: 1, foo: 'foo', bar: 'bar' )}
context "with identifier" do
subject { described_class.build(record, identifier: identifier).value }
let(:identifier) { :id }
context "proc identifier" do
let(:identifier) { l... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/integration/ephermal_model_spec.rb | Ruby | mit | 19 | master | 939 | require 'spec_helper'
describe "Publishing of ephermal models" do
let(:ephermal_class) do
Class.new do
def self.name
'Ephermal'
end
attr_accessor :foo, :bar, :baz, :id
def initialize(params)
self.id = params[:id]
self.foo = params[:foo]
self.bar = params[:... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/mixins/subscriber_spec.rb | Ruby | mit | 19 | master | 378 | require 'spec_helper'
describe MultipleMan::Subscriber do
class MockClass
include MultipleMan::Subscriber
end
describe "subscribe" do
it "should register itself" do
expect(MultipleMan.configuration).to receive(:register_listener).with(instance_of(MultipleMan::Subscribers::ModelSubscriber))
M... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/mixins/publisher_spec.rb | Ruby | mit | 19 | master | 868 | require 'spec_helper'
describe MultipleMan::Publisher do
class MockClass
class << self
attr_accessor :subscriber
def after_commit(subscriber)
self.subscriber = subscriber
end
end
include MultipleMan::Publisher
def save
self.multiple_man_publish
end
end
desc... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/mixins/listener_spec.rb | Ruby | mit | 19 | master | 546 | require 'spec_helper'
describe MultipleMan::Subscriber do
let(:mock_class) do
Class.new do
include MultipleMan::Listener
end
end
describe "listen_to" do
it "should register itself" do
MultipleMan.configuration.should_receive(:register_listener).with(instance_of(mock_class))
mock_c... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/consumers/general_spec.rb | Ruby | mit | 19 | master | 4,049 | require 'spec_helper'
describe MultipleMan::Consumers::General do
let(:listener1) {
Class.new do
include MultipleMan::Listener
def initialize
self.listen_to = 'SomeClass'
self.operation = '#'
end
end
}
let(:listener2) {
Class.new do
include MultipleMan::Liste... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/consumers/seed_spec.rb | Ruby | mit | 19 | master | 2,134 | require 'spec_helper'
describe MultipleMan::Consumers::Seed do
let(:listener1) {
Class.new do
include MultipleMan::Listener
def initialize
self.listen_to = 'SomeClass'
self.operation = '#'
end
end
}
it 'binds for seeding' do
channel = double(Bunny::Channel).as_null... |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/subscribers/registry_spec.rb | Ruby | mit | 19 | master | 282 | require 'spec_helper'
describe MultipleMan::Subscribers::Registry do
describe "register" do
it "should add a subscriber" do
subscription = double(:subscriber)
subject.register(subscription)
subject.subscriptions[0].should == subscription
end
end
end |
github | influitive/multiple_man | https://github.com/influitive/multiple_man | spec/subscribers/model_subscriber_spec.rb | Ruby | mit | 19 | master | 1,749 | require 'spec_helper'
describe MultipleMan::Subscribers::ModelSubscriber do
class MockClass
end
describe "initialize" do
it "should listen to the object passed in for to" do
subscriber = described_class.new(MockClass, to: 'PublishedClass')
expect(subscriber.klass).to eq("PublishedClass")
en... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.