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 | djezzzl/n1_loader | https://github.com/djezzzl/n1_loader | examples/reloading.rb | Ruby | mit | 233 | master | 758 | require 'n1_loader'
require_relative 'context/service'
class User
include N1Loader::Loadable
n1_optimized :optimized_call do |users|
data = Service.receive(users)
users.each_with_index do |user, index|
fulfill(user, data[index])
end
end
end
users = [User.new, User.new, User.new]
# Initiali... |
github | djezzzl/n1_loader | https://github.com/djezzzl/n1_loader | examples/context/service.rb | Ruby | mit | 233 | master | 329 | # 3rd party service, or database, or anything else that can perform in batches
class Service
def self.count
@count ||= 0
end
def self.increase!
@count = (@count || 0) + 1
end
def self.receive(*users)
increase!
users.flatten.map(&:object_id)
end
def self.single(user)
user.object_id
... |
github | djezzzl/n1_loader | https://github.com/djezzzl/n1_loader | examples/context/setup_ar_lazy.rb | Ruby | mit | 233 | master | 649 | ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.include(ArLazyPreload::Base)
ActiveRecord::Relation.prepend(ArLazyPreload::Relation)
ActiveRecord::AssociationRelation.prepend(ArLazyPreload::AssociationRelation)
ActiveRecord::Relation::Merger.prepend(ArLazyPreload::Merger)
[
ActiveRecord::Ass... |
github | djezzzl/n1_loader | https://github.com/djezzzl/n1_loader | examples/context/setup_database.rb | Ruby | mit | 233 | master | 626 | require "sqlite3"
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.connection.tables.each do |table|
ActiveRecord::Base.connection.drop_table(table, force: :cascade)
end
ActiveRecord::Schema.verbose = false
ActiveRecord::Base.logger = Logger.new($stdout)
ActiveRec... |
github | zombocom/heapy | https://github.com/zombocom/heapy | heapy.gemspec | Ruby | mit | 233 | main | 980 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'heapy/version'
Gem::Specification.new do |spec|
spec.name = "heapy"
spec.version = Heapy::VERSION
spec.authors = ["schneems"]
spec.email = ["richard.schneeman... |
github | zombocom/heapy | https://github.com/zombocom/heapy | spec/spec_helper.rb | Ruby | mit | 233 | main | 397 | $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'heapy'
require 'pathname'
require "open3"
require 'tempfile'
def fixtures(name)
Pathname.new(File.expand_path("../fixtures", __FILE__)).join(name)
end
def run(cmd)
out = ""
Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
err = stde... |
github | zombocom/heapy | https://github.com/zombocom/heapy | spec/heap_inspect_spec.rb | Ruby | mit | 233 | main | 2,275 | require 'spec_helper'
describe Heapy do
it 'has a version number' do
expect(Heapy::VERSION).not_to be nil
end
describe "heap diffs" do
it "diffs 2 heaps" do
out = run("bin/heapy diff #{fixtures('dumps/diff/my_dump_1.json')} #{fixtures('dumps/diff/my_dump_2.json')}")
expect(out).to match("All... |
github | zombocom/heapy | https://github.com/zombocom/heapy | lib/heapy.rb | Ruby | mit | 233 | main | 3,586 | require 'json'
require 'thor'
require "heapy/version"
module Heapy
class CLI < Thor
def self.exit_on_failure?
true
end
desc "read <file> <generation> --lines <number_of_lines>", "Read heap dump file"
long_desc <<-DESC
When run with only a file input, it will output the generation and co... |
github | zombocom/heapy | https://github.com/zombocom/heapy | lib/heapy/diff.rb | Ruby | mit | 233 | main | 3,416 | # frozen_string_literal: true
require 'json'
module Heapy
# Diff 2 dumps example:
#
# Heapy::Diff.new(before: 'my_dump_1.json', after: 'my_dump_2.json').call
#
# This will find objects that are present in my_dump_2 that are not present in my_dump_1
# this means they were allocated sometime between the tw... |
github | zombocom/heapy | https://github.com/zombocom/heapy | lib/heapy/analyzer.rb | Ruby | mit | 233 | main | 6,323 | module Heapy
# Used for inspecting contents of a heap dump
#
# To glance all contents at a glance run:
#
# Analyzer.new(file_name).analyze
#
# To inspect contents of a specific generation run:
#
# Analyzer.new(file_name).drill_down(generation, Float::INFINITY)
class Analyzer
def initialize(... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | Rakefile | Ruby | mit | 233 | master | 1,444 | # encoding: utf-8
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | Gemfile | Ruby | mit | 233 | master | 200 | source "http://rubygems.org"
gem "thor"
gem 'guard'
gem "sprockets"
gem "rubyzip"
gem "json"
gem "sass"
gem "sprockets-sass"
gem "compass"
gem 'rack'
gem "less"
gem "rb-fsevent"
gem "yui-compressor" |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | forge.gemspec | Ruby | mit | 233 | master | 4,961 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "forge"
s.version = "0.5.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_v... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | spec/spec_helper.rb | Ruby | mit | 233 | master | 363 | $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(File.dirname(__FILE__))
require 'rspec'
require 'forge'
p "HEY"
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| requ... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | spec/lib/forge/project_spec.rb | Ruby | mit | 233 | master | 763 | require 'forge/project'
describe Forge::Project do
before(:each) do
@project = Forge::Project.new('/tmp/', nil, {:name => 'Hello'})
end
describe :config_file do
it "should create an expanded path to the config file" do
@project.config_file.should == '/tmp/config.json'
end
end
describe :as... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | spec/lib/forge/config_spec.rb | Ruby | mit | 233 | master | 2,171 | require 'forge/config'
describe Forge::Config do
def config_file
File.expand_path(File.join('~', '.forge', 'config.yml'))
end
before(:each) do
@buffer = StringIO.new
@config = Forge::Config.new
end
it "should provide empty config object by default" do
@config.config.should == {
:them... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge.rb | Ruby | mit | 233 | master | 318 | require 'forge/error'
module Forge
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
autoload :Guard, 'forge/guard'
autoload :CLI, 'forge/cli'
autoload :Project, 'forge/project'
autoload :Builder, 'forge/builder'
autoload :Generator, 'forge/generator'
autoload :Config, 'forge/config'
end |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/builder.rb | Ruby | mit | 233 | master | 9,291 | require 'sprockets'
require 'sprockets-sass'
require 'sass'
require 'less'
require 'zip'
require 'forge/engines'
module Forge
class Builder
def initialize(project)
@project = project
@task = project.task
@templates_path = @project.templates_path
@assets_path = @project.assets_path
... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/engines.rb | Ruby | mit | 233 | master | 290 | module Tilt
class LessTemplateWithPaths < LessTemplate
class << self
attr_accessor :load_path
end
def prepare
parser = ::Less::Parser.new(:filename => eval_file, :line => line, :paths => [self.class.load_path])
@engine = parser.parse(data)
end
end
end |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/project.rb | Ruby | mit | 233 | master | 4,237 | require 'pathname'
require 'compass'
module Forge
class Project
class << self
def create(root, config, task)
root = File.expand_path(root)
project = self.new(root, task, config)
Generator.run(project)
project
end
end
attr_accessor :root, :config, :task
... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/guard.rb | Ruby | mit | 233 | master | 1,758 | require 'guard'
require 'guard/compat/plugin'
module Forge
module Guard
class << self
attr_accessor :project, :task, :builder
end
def self.add_guard(&block)
@additional_guards ||= []
@additional_guards << block
end
def self.start(project, task, options={}, livereload={})
... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/generator.rb | Ruby | mit | 233 | master | 3,383 | module Forge
class Generator
class << self
def run(project, layout='default')
generator = self.new(project, layout)
generator.run
end
end
def initialize(project, layout='default')
@project = project
@task = project.task
@layout = layout
end
def c... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/cli.rb | Ruby | mit | 233 | master | 2,660 | require 'thor'
require 'yaml'
require 'guard/forge/assets'
require 'guard/forge/config'
require 'guard/forge/templates'
require 'guard/forge/functions'
module Forge
class CLI < Thor
include Thor::Actions
def self.source_root
File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'layouts'))
... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/forge/config.rb | Ruby | mit | 233 | master | 1,316 | module Forge
# Reads/Writes a configuration file in the user's home directory
#
class Config
@config
attr_accessor :config
def initialize()
@config = {
:theme => {
:author => nil,
:author_url => nil,
},
:links => []
}
end
# Provid... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/guard/forge/config.rb | Ruby | mit | 233 | master | 982 | require 'guard'
require 'guard/compat/plugin'
module Guard
class ForgeConfig < Plugin
def initialize(watchers=[], options={})
super
end
# Called on Ctrl-Z signal
# This method should be mainly used for "reload" (really!) actions like reloading passenger/spork/bundler/...
def reload
U... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/guard/forge/templates.rb | Ruby | mit | 233 | master | 645 | require 'guard'
require 'guard/compat/plugin'
module Guard
class ForgeTemplates < Plugin
def initialize(watchers=[], options={})
super
end
def start
UI.info "Copying templates over"
::Forge::Guard.builder.copy_templates
end
def run_all
UI.info "Rebuilding all templates"
... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/guard/forge/functions.rb | Ruby | mit | 233 | master | 862 | require 'guard'
require 'guard/compat/plugin'
module Guard
class ForgeFunctions < Plugin
def initialize(watchers=[], options={})
super
end
def start
UI.info "Copying functions over"
::Forge::Guard.builder.copy_functions
::Forge::Guard.builder.copy_includes
end
def run_al... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | lib/guard/forge/assets.rb | Ruby | mit | 233 | master | 747 | require 'guard'
require 'guard/compat/plugin'
module Guard
class ForgeAssets < Plugin
def initialize(watchers=[], options={})
super
end
def start
UI.info "Building all assets"
::Forge::Guard.builder.build_assets
end
# Called on Ctrl-\ signal
# This method should be princi... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | features/support/env.rb | Ruby | mit | 233 | master | 467 | require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
file_path = Pathname.new(__FILE__).realpath
libdir = File.join(File.dirname(File.dirname(File.dirname(file_pa... |
github | thethemefoundry/forge | https://github.com/thethemefoundry/forge | features/step_definitions/forge_steps.rb | Ruby | mit | 233 | master | 949 | Given /^I am in a forge project named "([^"]*)"$/ do |name|
cli = Forge::CLI.new
cli.shell.mute do
Forge::Project.create(File.join(current_dir, name), {:name => name}, cli)
end
cd name
end
Given /^a WordPress installation exists at "([^"]*)"$/ do |directory|
create_dir directory
end
Then /^the file "(... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | Gemfile | Ruby | mit | 232 | master | 610 | source "http://rubygems.org"
# Declare your gem's dependencies in has-many-with-set.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# jquery-rails is used by the dummy application
#gem "jquery-rails"
... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | has-many-with-set.gemspec | Ruby | mit | 232 | master | 792 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "has-many-with-set/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "has-many-with-set"
s.version = HasManyWithSet::VERSION
s.authors = ["Francisco Soto"]
s.email... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | Rakefile | Ruby | mit | 232 | master | 364 | #!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | test/has-many-with-set_test.rb | Ruby | mit | 232 | master | 3,033 | require "test_helper"
PARENT = "One"
CHILD = "Two"
MIGRATION_PATH = "test/tmp/"
MIGRATION_FILE = "db/migrate/create_ones_twos_set"
PrepareActiveRecord.prepare_default_schema
class MigrationGeneratorTest < Rails::Generators::TestCase
tests HasManyWithSet::MigrationGenerator
destination MIGRATION_PATH
setup :p... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | test/test_helper.rb | Ruby | mit | 232 | master | 365 | require "active_record"
require "active_support"
require "rails"
require "rails/generators"
require "rails/test_help"
require File.expand_path("lib/has-many-with-set")
require "generators/has_many_with_set/migration_generator"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE_... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | test/support/prepare_activerecord.rb | Ruby | mit | 232 | master | 812 | class PrepareActiveRecord
class << self
def prepare_default_schema
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
ActiveRecord::Schema.define do
self.verbose = false
create_table :ones do |t|
t.integer :num
t.timestamps
... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set.rb | Ruby | mit | 232 | master | 419 | require "active_record"
require "active_support"
$LOAD_PATH.unshift(File.dirname(__FILE__))
require "has-many-with-set/has-many-with-set"
require "has-many-with-set/relationships"
require "has-many-with-set/queries"
require "has-many-with-set/accessors"
require "has-many-with-set/callbacks"
module HasManyWithSet
end... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set/relationships.rb | Ruby | mit | 232 | master | 1,218 | module HasManyWithSet
module Relationships
def self.create_set_model(set_model_name)
Object.const_set(set_model_name, Class.new(ApplicationRecord)) unless
Object.const_defined?(set_model_name) # this *should* never happen...
end
def self.relate_child_to_set(set_model_name, child_model_name)... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set/has-many-with-set.rb | Ruby | mit | 232 | master | 2,577 | module HasManyWithSet
# This is the magic entry point method that adds set relationships to a model.
def has_many_with_set(child)
build_set_relationship self.to_s, child.to_s.classify
end
private
def build_set_relationship(parent_model_name, child_model_name)
parent_table_name = parent... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set/queries.rb | Ruby | mit | 232 | master | 1,584 | module HasManyWithSet
module Queries
def self.build_find_empty_set_query(set_table_name, set_items_table_name)
"select #{ set_table_name }.id from #{ set_table_name }
where not exists (select null from #{ set_items_table_name }
where #{ set_items_table_name }.#{ set_table_nam... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set/callbacks.rb | Ruby | mit | 232 | master | 1,553 | module HasManyWithSet
module Callbacks
def self.build_saver_callback(set_table_name, set_items_table_name,
child_table_name, instance_var_name)
empty_set_query = Queries.build_find_empty_set_query(set_table_name, set_items_table_name)
find_set_query = Queries.build_fi... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/has-many-with-set/accessors.rb | Ruby | mit | 232 | master | 1,662 | module HasManyWithSet
module Accessors
def self.build_loader_method(child_table_name, set_table_name)
set_table_id = "#{ set_table_name.singularize }_id".to_sym
set_table_name_singular = set_table_name.singularize.to_sym
Proc.new do
values = []
values = send(set_table_name_sing... |
github | ebobby/has-many-with-set | https://github.com/ebobby/has-many-with-set | lib/generators/has_many_with_set/migration_generator.rb | Ruby | mit | 232 | master | 1,207 | require 'rails/generators'
module HasManyWithSet
class MigrationGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
def self.next_migration_number(path)
Time.now.utc.strftime("%Y%m%d%H%M%S")
end
ORM_IDENTIFIER_SI... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | Gemfile | Ruby | mit | 232 | master | 386 | source 'https://rubygems.org'
# Specify your gem's dependencies in ansible_spec.gemspec
gemspec
if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
# net-ssh 3.x dropped Ruby 1.8 and 1.9 support.
gem 'net-ssh', '~> 2.7'
end
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1')
# Ansibl... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | ansible_spec.gemspec | Ruby | mit | 232 | master | 1,347 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'ansible_spec/version'
Gem::Specification.new do |gem|
gem.name = "ansible_spec"
gem.version = AnsibleSpec::VERSION
gem.authors = ["volanja"]
gem.email ... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | lib/ansible_spec.rb | Ruby | mit | 232 | master | 2,207 | require "ansible_spec/version"
require "ansible_spec/load_ansible"
require "fileutils"
# Reference
# https://github.com/serverspec/serverspec/blob/master/lib/serverspec/setup.rb
# Reference License (MIT)
# https://github.com/serverspec/serverspec/blob/master/LICENSE.txt
module AnsibleSpec
def self.main()
safe_... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | lib/src/Rakefile | Ruby | mit | 232 | master | 1,874 | require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
require 'ansible_spec'
properties = AnsibleSpec.get_properties
# {"name"=>"Ansible-Sample-TDD", "hosts"=>["192.168.0.103","192.168.0.103"], "user"=>"root", "roles"=>["nginx", "mariadb"]}
# {"name"=>"Ansible-Sample-TDD", "hosts"=>[{"name" => "192.168.0.103:22... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | lib/src/spec/spec_helper.rb | Ruby | mit | 232 | master | 2,421 | require 'serverspec'
require 'net/ssh'
require 'ansible_spec'
require 'winrm'
#
# Set ansible variables to serverspec property
#
host = ENV['TARGET_HOST']
hosts = ENV["TARGET_HOSTS"]
group_idx = ENV['TARGET_GROUP_INDEX'].to_i
vars = AnsibleSpec.get_variables(host, group_idx,hosts)
ssh_config_file = AnsibleSpec.get_ss... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | lib/ansible_spec/load_ansible.rb | Ruby | mit | 232 | master | 18,404 | # -*- coding: utf-8 -*-
require 'hostlist_expression'
require 'oj'
require 'open3'
require 'yaml'
require 'inifile'
require 'ansible_spec/vendor/hash'
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1')
require 'ansible/vault'
end
module AnsibleSpec
# param: inventory file of Ansible
# param: return... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/get_variable_hosts_childrens_spec.rb | Ruby | mit | 232 | master | 11,776 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
require 'pp'
describe "Dynamic Inventoryによるchildrenの依存関係を参照し、get_variablesの実行" do
context 'Correct operation : develop groups by web-serers hosts childrens' do
before do
@current_dir = Dir.pwd()
Dir.chdir('spec/case/get_variable/group_vars_ho... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/load_ansible_cfg_ssh_spec.rb | Ruby | mit | 232 | master | 3,343 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
def create_file(name,content)
dir = File.dirname(name)
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
File.open(name, 'w') do |f|
f.puts content
end
end
describe "get_ssh_config_file" do
context 'with SSH_CONFIG_FILE set' do
tm... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/dynamic_inventory_hosts_childrens_spec.rb | Ruby | mit | 232 | master | 7,449 | # coding: utf-8
require 'ansible_spec'
describe "Dynamic InventoryでChildren関係でhostsを指定しload_targetsの実行" do
context '正常系:develop-env DynamicInventory:8 Group, 2 hosts' do
tmp_hosts = 'hosts'
before do
content_h = <<'EOF'
#!/bin/bash
#echo '{"database-servers": {"hosts": ["host1.example.com"],"vars":{"a... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/inventory_parameters_spec.rb | Ruby | mit | 232 | master | 7,191 | # coding: utf-8
require 'ansible_spec'
def create_file(name,content)
File.open(name, 'w') do |f|
f.puts content
end
end
def ready_test
tmp_hosts = 'hosts'
tmp_ansiblespec = '.ansiblespec'
tmp_playbook = 'site.yml'
content = <<'EOF'
---
-
playbook: site.yml
inventory: hosts
EOF
content_p = <<'E... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/ssh_spec.rb | Ruby | mit | 232 | master | 6,446 | require 'spec_helper'
require 'ansible_spec'
require 'yaml'
set :backend, :ssh
describe 'ssh' do
context 'with root user' do
before do
create_normality
properties = AnsibleSpec.get_properties
@h = Hash.new
n = 0
properties.each do |property|
property["hosts"].each do |host... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/load_ansible_spec.rb | Ruby | mit | 232 | master | 44,203 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
def create_file(name,content)
dir = File.dirname(name)
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
File.open(name, 'w') do |f|
f.puts content
end
end
describe "load_targetsの実行" do
context '正常系:1グループ' do
tmp_hosts = 'hosts'
... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/spec_helper.rb | Ruby | mit | 232 | master | 4,393 | require 'specinfra'
require 'rspec/mocks/standalone'
require 'specinfra/helper/set'
require 'simplecov'
include Specinfra::Helper::Set
# Test Coverage
SimpleCov.start
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/ec2_dynamic_inventory_spec.rb | Ruby | mit | 232 | master | 2,722 | # coding: utf-8
require 'ansible_spec'
describe "load_targets_ec2" do
context 'EC2_DynamicInventory' do
tmp_hosts = 'hosts'
before do
content_h = <<'EOF'
#!/bin/bash
echo '{ "_meta": { "hostvars": { "some_key1": { "ec2_something_something": false }, "some_key2": { "ec2_something_something": true }}}, "... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/get_variable_spec.rb | Ruby | mit | 232 | master | 19,844 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
describe "get_variablesの実行" do
context 'Correct operation : roles default' do
before do
@current_dir = Dir.pwd()
Dir.chdir('spec/case/get_variable/roles_default/')
@res = AnsibleSpec.get_variables('192.168.1.1', 0)
end
it 'res ... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/get_variable_vars_dirs_path_spec.rb | Ruby | mit | 232 | master | 9,489 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
describe "Run get_variables" do
context 'Correct operation : env VARS_DIRS_PATH=inventories/staging - all groups' do
require 'yaml'
tmp_playbook = 'site.yml'
tmp_inventory_file = 'inventories/staging/hosts'
tmp_vars_dirs_path = 'inventories/s... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/commands_spec.rb | Ruby | mit | 232 | master | 1,449 | # coding: utf-8
require 'ansible_spec'
require 'diff/lcs'
created_file = [
"spec/spec_helper.rb",
"Rakefile",
".ansiblespec"
]
created_dir = [
"spec",
]
test_dir = "tmp"
describe "モジュールの実行" do
# テスト実行前
before do
$stdout = File.open("/dev/null", "w") #テスト実行中は標準出力は/dev/nullにする。
FileUtils.mkdir_p(test_dir) u... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/get_vars_dirs_path_spec.rb | Ruby | mit | 232 | master | 4,247 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
def create_file(name,content)
dir = File.dirname(name)
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
File.open(name, 'w') do |f|
f.puts content
end
end
describe "Run get_vars_dirs_path" do
context 'Normal system (environment varia... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/load_ansible_cfg_spec.rb | Ruby | mit | 232 | master | 1,996 | # coding: utf-8
require 'fileutils'
require 'ansible_spec'
def create_file(name,content)
dir = File.dirname(name)
unless File.directory?(dir)
FileUtils.mkdir_p(dir)
end
File.open(name, 'w') do |f|
f.puts content
end
end
describe "load_ansible_cfg" do
context 'with ANSIBLE_CFG set' do
tmp_cfg =... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/dependency_spec.rb | Ruby | mit | 232 | master | 2,294 | # coding: utf-8
require 'ansible_spec'
describe "load_dependencies" do
tmp_hosts = 'hosts'
tmp_ansiblespec = '.ansiblespec'
tmp_playbook = 'site.yml'
tmp_webapp_meta = 'roles/webapp/meta/main.yml'
tmp_dep1_meta = 'roles/dep1/meta/main.yml'
spec_content = <<'EOF'
---
-
playbook: site.yml
inventory: hosts
... |
github | volanja/ansible_spec | https://github.com/volanja/ansible_spec | spec/dynamic_inventory_spec.rb | Ruby | mit | 232 | master | 3,371 | # coding: utf-8
require 'ansible_spec'
describe "load_targetsの実行" do
context '正常系:DynamicInventory:1 Group, 1 hosts' do
tmp_hosts = 'hosts'
before do
content_h = <<'EOF'
#!/bin/bash
echo '{"databases": {"hosts": ["host1.example.com"],"vars":{"a": true}}}'
EOF
create_file(tmp_hosts,content_h)
... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | rubocop-daemon.gemspec | Ruby | mit | 232 | master | 1,095 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rubocop/daemon/version'
Gem::Specification.new do |spec|
spec.name = 'rubocop-daemon'
spec.version = RuboCop::Daemon::VERSION
spec.authors = ['Hayato Kawai']... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | Gemfile | Ruby | mit | 232 | master | 201 | # frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in rubocop-daemon.gemspec
gemspec |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon.rb | Ruby | mit | 232 | master | 920 | # frozen_string_literal: true
module RuboCop
module Daemon
TIMEOUT = 20
autoload :VERSION, 'rubocop/daemon/version'
autoload :CLI, 'rubocop/daemon/cli'
autoload :Cache, 'rubocop/daemon/cache'
autoload :ClientCommand, 'rubocop/daemon/client_command'
autoload :Helper, 'rubocop/daemon/helper'
... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/server.rb | Ruby | mit | 232 | master | 1,307 | # frozen_string_literal: true
require 'socket'
require 'shellwords'
require 'securerandom'
module RuboCop
module Daemon
class Server
attr_reader :verbose
def self.token
@token ||= SecureRandom.hex(4)
end
def initialize(verbose)
@verbose = verbose
end
def to... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/cache.rb | Ruby | mit | 232 | master | 2,129 | # frozen_string_literal: true
require 'pathname'
module RuboCop
module Daemon
class Cache
class << self
# Searches for Gemfile or gems.rb in the current dir or any parent dirs
def project_dir
current_dir = Dir.pwd
while current_dir != '/'
return current_dir ... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/errors.rb | Ruby | mit | 232 | master | 331 | # frozen_string_literal: true
module RuboCop
module Daemon
class GemfileNotFound < StandardError; end
class InvalidTokenError < StandardError; end
class ServerStopRequest < StandardError; end
class UnknownClientCommandError < StandardError; end
class UnknownServerCommandError < StandardError; end... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/cli.rb | Ruby | mit | 232 | master | 1,385 | # frozen_string_literal: true
require 'optparse'
module RuboCop
module Daemon
class CLI
def self.new_parser(&_block)
OptionParser.new do |opts|
opts.version = VERSION
yield(opts)
end
end
def run(argv = ARGV)
parser.order!(argv)
return if arg... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/socket_reader.rb | Ruby | mit | 232 | master | 1,515 | # frozen_string_literal: true
module RuboCop
module Daemon
class SocketReader
Request = Struct.new(:header, :body)
Header = Struct.new(:token, :cwd, :command, :args)
def initialize(socket, verbose)
@socket = socket
@verbose = verbose
end
def read!
request =... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/helper.rb | Ruby | mit | 232 | master | 474 | # frozen_string_literal: true
module RuboCop
module Daemon
module Helper
def self.redirect(stdin: $stdin, stdout: $stdout, stderr: $stderr, &_block)
old_stdin = $stdin.dup
old_stdout = $stdout.dup
old_stderr = $stderr.dup
$stdin = stdin
$stdout = stdout
$std... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/server_command.rb | Ruby | mit | 232 | master | 282 | # frozen_string_literal: true
module RuboCop
module Daemon
module ServerCommand
autoload :Base, 'rubocop/daemon/server_command/base'
autoload :Exec, 'rubocop/daemon/server_command/exec'
autoload :Stop, 'rubocop/daemon/server_command/stop'
end
end
end |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command.rb | Ruby | mit | 232 | master | 471 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
autoload :Base, 'rubocop/daemon/client_command/base'
autoload :Exec, 'rubocop/daemon/client_command/exec'
autoload :Restart, 'rubocop/daemon/client_command/restart'
autoload :Start, 'rubocop/daemon/client_comm... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/server_command/base.rb | Ruby | mit | 232 | master | 660 | # frozen_string_literal: true
module RuboCop
module Daemon
module ServerCommand
class Base
module Runner
def run
validate_token!
Dir.chdir(@cwd) do
super
end
end
end
def self.inherited(child)
child.prep... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/server_command/exec.rb | Ruby | mit | 232 | master | 833 | # frozen_string_literal: true
module RuboCop
module Daemon
module ServerCommand
class Exec < Base
def run
Cache.status_path.delete if Cache.status_path.file?
# RuboCop output is colorized by default where there is a TTY.
# We must pass the --color option to preserve th... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/server_command/stop.rb | Ruby | mit | 232 | master | 201 | # frozen_string_literal: true
module RuboCop
module Daemon
module ServerCommand
class Stop < Base
def run
raise ServerStopRequest
end
end
end
end
end |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/stop.rb | Ruby | mit | 232 | master | 491 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
class Stop < Base
def run
return unless check_running_server
parser.parse(@argv)
send_request(command: 'stop')
Daemon.wait_for_running_status!(false)
end
private... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/start.rb | Ruby | mit | 232 | master | 1,051 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
class Start < Base
def run
if Daemon.running?
warn 'rubocop-daemon: server is already running.'
return
end
Cache.acquire_lock do |locked|
unless locked
... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/restart.rb | Ruby | mit | 232 | master | 520 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
class Restart < Base
def run
parser.parse(@argv)
ClientCommand::Stop.new([]).run
ClientCommand::Start.new(@argv).run
end
private
def parser
@parser ||= ... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/base.rb | Ruby | mit | 232 | master | 962 | # frozen_string_literal: true
require 'shellwords'
require 'socket'
module RuboCop
module Daemon
module ClientCommand
class Base
def initialize(argv)
@argv = argv.dup
@options = {}
end
def run; end
private
def send_request(command:, args: [], ... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/status.rb | Ruby | mit | 232 | master | 515 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
class Status < Base
def run
parser.parse(@argv)
if Daemon.running?
puts 'rubocop-daemon is running.'
else
puts 'rubocop-daemon is not running.'
end
... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | lib/rubocop/daemon/client_command/exec.rb | Ruby | mit | 232 | master | 989 | # frozen_string_literal: true
module RuboCop
module Daemon
module ClientCommand
class Exec < Base
def run
args = parser.parse(@argv)
ensure_server!
Cache.status_path.delete if Cache.status_path.file?
send_request(
command: 'exec',
args... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | spec/spec_helper.rb | Ruby | mit | 232 | master | 401 | # frozen_string_literal: true
require 'bundler/setup'
require 'rubocop/daemon'
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = '.rspec_status'
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monke... |
github | fohte/rubocop-daemon | https://github.com/fohte/rubocop-daemon | spec/rubocop/daemon_spec.rb | Ruby | mit | 232 | master | 226 | # frozen_string_literal: true
RSpec.describe RuboCop::Daemon do
it 'has a version number' do
expect(RuboCop::Daemon::VERSION).not_to be nil
end
it 'does something useful' do
expect(false).to eq(true)
end
end |
github | amatsuda/himl | https://github.com/amatsuda/himl | Gemfile | Ruby | mit | 232 | master | 308 | # frozen_string_literal: true
source "https://rubygems.org"
# Specify your gem's dependencies in himl.gemspec
gemspec
if ENV['RAILS_VERSION'] == 'edge'
gem 'rails', git: 'https://github.com/rails/rails.git'
elsif ENV['RAILS_VERSION']
gem 'rails', "~> #{ENV['RAILS_VERSION']}.0"
else
gem 'rails'
end |
github | amatsuda/himl | https://github.com/amatsuda/himl | himl.gemspec | Ruby | mit | 232 | master | 1,241 | lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "himl/version"
Gem::Specification.new do |spec|
spec.name = "himl"
spec.version = Himl::VERSION
spec.authors = ["Akira Matsuda"]
spec.email = ["ronnie@dio.jp"]
spec.summary... |
github | amatsuda/himl | https://github.com/amatsuda/himl | lib/himl/handler.rb | Ruby | mit | 232 | master | 643 | # frozen_string_literal: true
module Himl
class Handler
ERB_HANDLER = ActionView::Template.handler_for_extension('erb')
def self.call(template, source = nil)
new.call(template, source || template.source)
end
def call(template, source)
erb = Himl::Parser.new.call(source).to_erb
es... |
github | amatsuda/himl | https://github.com/amatsuda/himl | lib/himl/railtie.rb | Ruby | mit | 232 | master | 369 | # frozen_string_literal: true
begin
require 'rails'
module Himl
class Railtie < ::Rails::Railtie
initializer 'himl' do
ActiveSupport.on_load :action_view do
require_relative 'handler'
ActionView::Template.register_template_handler :himl, Himl::Handler
end
end
... |
github | amatsuda/himl | https://github.com/amatsuda/himl | lib/himl/parser.rb | Ruby | mit | 232 | master | 5,635 | # frozen_string_literal: true
require 'nokogiri'
module Himl
class Parser
class Document < Nokogiri::XML::SAX::Document
Tag = Struct.new(:name, :indentation, :line, :block_end) do
def end_tag
if has_block?
"#{' ' * indentation}<% #{block_end} %>\n"
else
... |
github | amatsuda/himl | https://github.com/amatsuda/himl | test/himl_test.rb | Ruby | mit | 232 | master | 5,381 | # frozen_string_literal: true
require 'test_helper'
class HimlTest < Test::Unit::TestCase
private def parse(template)
Himl::Parser.new.call(template).to_erb
end
def test_single_open_and_close
assert_equal <<-HTML, parse(<<-TEMPLATE)
<div>
</div>
HTML
<div>
</div>
TEMPLATE
end
def test_single_open
... |
github | amatsuda/himl | https://github.com/amatsuda/himl | test/himl_error_test.rb | Ruby | mit | 232 | master | 846 | # frozen_string_literal: true
require 'test_helper'
class HimlErrorTest < Test::Unit::TestCase
private def parse(template)
Himl::Parser.new.call(template).to_erb
end
private def assert_syntax_error(message = '', &block)
assert_raise SyntaxError, message, &block
end
def test_close_mismatch_1
as... |
github | frozon/passbook | https://github.com/frozon/passbook | passbook.gemspec | Ruby | mit | 232 | master | 4,066 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: passbook 0.4.4 ruby lib
Gem::Specification.new do |s|
s.name = "passbook"
s.version = "0.4.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if... |
github | frozon/passbook | https://github.com/frozon/passbook | Rakefile | Ruby | mit | 232 | master | 1,120 | #!/usr/bin/env rake
require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is... |
github | frozon/passbook | https://github.com/frozon/passbook | Gemfile | Ruby | mit | 232 | master | 310 | source 'https://rubygems.org'
# Specify your gem's dependencies in passbook.gemspec
gem 'rubyzip', '>= 1.0.0'
gem 'grocer'
gem 'commander'
gem 'terminal-table'
group :test, :development do
gem 'rack-test'
gem 'activesupport'
gem 'jeweler'
gem 'simplecov'
gem 'rspec'
gem 'rake'
gem 'yard'
end |
github | frozon/passbook | https://github.com/frozon/passbook | lib/passbook.rb | Ruby | mit | 232 | master | 427 | require "passbook/version"
require "passbook/pkpass"
require "passbook/signer"
require 'active_support/core_ext/module/attribute_accessors'
require 'passbook/push_notification'
require 'grocer'
require 'rack/passbook_rack'
module Passbook
mattr_accessor :p12_certificate, :p12_password, :wwdc_cert, :p12_key, :notific... |
github | frozon/passbook | https://github.com/frozon/passbook | lib/utils/command_utils.rb | Ruby | mit | 232 | master | 249 | # this was added for testability because I couldn't figure out something better.
class CommandUtils
def self.get_assets(directory)
Dir[File.join(directory, '*')]
end
def self.get_current_directory
File.dirname(__FILE__)
end
end |
github | frozon/passbook | https://github.com/frozon/passbook | lib/rails/generators/passbook/config/config_generator.rb | Ruby | mit | 232 | master | 698 | module Passbook
module Generators
class ConfigGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)
argument :wwdc_cert_path, type: :string, default: '', optional: true, banner: "Absolute path to your wwdc cert file"
argument :p12_cert_path, type: :string, d... |
github | frozon/passbook | https://github.com/frozon/passbook | lib/rails/generators/passbook/config/templates/initializer.rb | Ruby | mit | 232 | master | 306 | require 'passbook'
Passbook.configure do |passbook|
# Path to your wwdc cert file
passbook.wwdc_cert = '<%= wwdc_cert_path %>'
# Path to your cert.p12 file
passbook.p12_certificate = '<%= p12_cert_path %>'
# Password for your certificate
passbook.p12_password = '<%= p12_password %>'
end |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.