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 | sonots/haikanko | https://github.com/sonots/haikanko | Rakefile | Ruby | mit | 46 | master | 353 | # encoding: utf-8
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
task :default => :spec
desc "Open the console"
task :console do
require_relative 'boot'
require 'irb'
# require 'irb/completion'
ARGV.clear
IR... |
github | sonots/haikanko | https://github.com/sonots/haikanko | Gemfile | Ruby | mit | 46 | master | 792 | # encoding: utf-8
source 'https://rubygems.org'
gem 'bootloader', git: 'https://github.com/ngmoco/bootloader'
gem 'activesupport'
gem 'mongoid', '~> 3.0'
gem 'rake'
group :web do
gem 'unicorn'
gem 'sinatra', require: 'sinatra/base'
gem 'sinatra-contrib'
gem 'dropkick'
end
group :pipework, :web do
gem 'mina... |
github | sonots/haikanko | https://github.com/sonots/haikanko | script/create_all_graph.rb | Ruby | mit | 46 | master | 4,019 | #!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require_relative '../boot'
require 'growthforecast-client'
require 'optparse'
$uri = FluentdConfig.growthforecast.uri
# parse options
OptionParser.new do |opt|
Version = "1.0.0"
opt.on('-u URI','--uri URI','URI of growthforecast such as http://localhost:5125') { |uri| ... |
github | sonots/haikanko | https://github.com/sonots/haikanko | script/setup_graph.rb | Ruby | mit | 46 | master | 4,482 | #!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
require_relative '../boot'
require 'growthforecast-client'
require 'optparse'
def try
begin
yield if block_given?
rescue => e
$stderr.puts "\tclass:#{e.class}\t#{e.message}"
end
end
$uri = FluentdConfig.growthforecast.uri
# parse options
OptionParser.new do ... |
github | sonots/haikanko | https://github.com/sonots/haikanko | lib/helper.rb | Ruby | mit | 46 | master | 398 | FluentdConfig.workers = (FluentdConfig.primary_workers || []) + (FluentdConfig.secondary_workers || []).uniq.sort
module Haikanko
module Helper
def self.included(base)
base.extend Helper
end
def report_time(&blk)
t = Time.now
output = yield
$logger.debug "Elapsed time: %.2f secon... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/spec_helper.rb | Ruby | mit | 46 | master | 944 | # encoding: utf-8
ENV['RACK_ENV'] = 'test'
require 'bundler/setup'
Bundler.require(:default, :test)
require_relative '../web/boot'
require 'capybara/rspec'
Dir["#{Bootloader.root_path}/spec/*/spec_helper.rb"].each { |f| require f }
Dir["#{Bootloader.root_path}/spec/support/**/*.rb"].each { |f| require f }
Dir["#{Boot... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/models/resource_spec.rb | Ruby | mit | 46 | master | 1,871 | # encoding: utf-8
require 'spec_helper'
%w(notifier visualizer irc host email role).each do |type|
describe type do
let(:resource) { Fabricate.build(type) }
describe "#new?" do
subject { resource.new? }
context "true" do
it { should == true }
end
context "false" do
... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/models/notifier_spec.rb | Ruby | mit | 46 | master | 2,866 | # encoding: utf-8
require 'spec_helper'
describe Notifier do
describe "#create" do
context "success" do
let(:attributes) do
{
label: 'arbitrary_label',
log_path: '/var/log/syslog',
regexp: 'warn',
exclude: 'exclude',
email_from: 'spec@haikanko.com'... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/fabricators/irc_fabricator.rb | Ruby | mit | 46 | master | 499 | # encoding: utf-8
Fabricator(:irc, class_name: "Irc") do
label "irc"
id "0"
channel "fluentd_warn"
staff "sonots seo"
end
Fabricator(:irc_one, class_name: "Irc") do
label "irc_one"
id "1"
channel "fluentd_warn"
staff "sonots seo"
end
Fabricator(:irc_two, class_name: "Irc") do
label "irc_two"
id "... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/fabricators/role_fabricator.rb | Ruby | mit | 46 | master | 326 | # encoding: utf-8
Fabricator(:role, class_name: "Role") do
label "role"
id "9"
end
Fabricator(:role_one, class_name: "Role") do
label "role_one"
id "1"
end
Fabricator(:role_two, class_name: "Role") do
label "role_two"
id "2"
end
Fabricator(:role_three, class_name: "Role") do
label "role_three"
id "3... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/fabricators/email_fabricator.rb | Ruby | mit | 46 | master | 534 | # encoding: utf-8
Fabricator(:email, class_name: "Email") do
label "email"
id "9"
email_to "test@example.com, debug@example.com"
end
Fabricator(:email_one, class_name: "Email") do
label "email_one"
id "1"
email_to "test@example.com, debug@example.com"
end
Fabricator(:email_two, class_name: "Email") do
... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/fabricators/host_fabricator.rb | Ruby | mit | 46 | master | 326 | # encoding: utf-8
Fabricator(:host, class_name: "Host") do
label "host"
id "9"
end
Fabricator(:host_one, class_name: "Host") do
label "host_one"
id "1"
end
Fabricator(:host_two, class_name: "Host") do
label "host_two"
id "2"
end
Fabricator(:host_three, class_name: "Host") do
label "host_three"
id "3... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/controllers/email_controller_spec.rb | Ruby | mit | 46 | master | 2,700 | # encoding: utf-8
require 'spec_helper'
shared_context 'edit_email_controller' do |button = 'Create', params = {}|
before do
fill_in 'email[label]', :with => params["label"] if params["label"]
fill_in 'email[email_to]', :with => params["email_to"] if params["email_to"]
click_button button
e... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/controllers/irc_controller_spec.rb | Ruby | mit | 46 | master | 2,740 | # encoding: utf-8
require 'spec_helper'
shared_context 'edit_irc_controller' do |button = 'Create', params = {}|
before do
fill_in 'irc[label]', :with => params["label"] if params["label"]
fill_in 'irc[channel]', :with => params["channel"] if params["channel"]
fill_in 'irc[staff]', :with => par... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/controllers/notifier_controller_spec.rb | Ruby | mit | 46 | master | 4,100 | # encoding: utf-8
require 'spec_helper'
shared_context 'edit_notifier_controller' do |button = 'Create', params = {}|
before do
# use default parameters
fill_in 'notifier[label]', :with => params["label"] if params["label"]
fill_in 'notifier[roles][0]', :with => params["roles"][0] if params["... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/fluentd/sample_spec.rb | Ruby | mit | 46 | master | 957 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
# @reference: http://blog.glidenote.com/blog/2012/07/15/fluentd-regex-debug/
format = /^(?<date>[^ ]+)\s+(?<duration>.*) (?<client address>.*) (?<result code>.*) (?<bytes>.*) (?<request method>.*) (?<url>.*) (?<rfc931>.*) (?<hierarchy code>.*) (?<type>.... |
github | sonots/haikanko | https://github.com/sonots/haikanko | spec/support/shared_examples_for_controller.rb | Ruby | mit | 46 | master | 550 | shared_examples_for 'success_controller' do
it { status_code.should == 200 }
it { page.find('div.alert-success').should be_visible }
end
%w(create update delete duplicate disable enable).each do |action|
shared_examples_for "#{action}_success_controller" do
it_should_behave_like "success_controller"
it {... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/boot.rb | Ruby | mit | 46 | master | 352 | # encoding: utf-8
require_relative '../boot'
Bundler.require(:default, :web)
I18n.load_path += Dir[File.join(File.dirname(__FILE__), '../config/locales/*.yml').to_s]
Bootloader.load_dir('web/lib')
Bootloader.load_dir('web/helpers')
require_relative 'controllers/resource_controller'
Bootloader.load_dir('web/controller... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/routes.rb | Ruby | mit | 46 | master | 435 | # encoding: utf-8
module Web
ROUTES = {
'/' => Web::FrontController,
'/web' => Web::FrontController,
'/web/notifier' => Web::NotifierController,
'/web/visualizer' => Web::VisualizerController,
'/web/irc' => Web::IrcController,
'/web/email' => Web::EmailC... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/lib/request_logger.rb | Ruby | mit | 46 | master | 1,148 | # encoding: utf-8
module Web
class RequestLogger
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
began_at = Time.now
begin
status, header, body = @app.call(env)
rescue => e
error = e
end
http_method = env['REQUEST_METHO... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/lib/rendering.rb | Ruby | mit | 46 | master | 342 | # encoding: utf-8
module Sinatra
module Rendering
module Helpers
def herb(template, options={})
erb(template, options.merge(:layout => :"#{settings.layout}"))
end
end
def self.registered(app)
app.helpers Rendering::Helpers
app.set :layout, 'default'
end
end
r... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/lib/sinatra_helper.rb | Ruby | mit | 46 | master | 1,329 | # encoding: utf-8
module SinatraHelper
def self.included(controller)
controller.helpers do
def h(text)
Rack::Utils.escape_html(text)
end
def checked_if(boolean)
attr_if(:checked, boolean)
end
def selected_if(boolean)
attr_if(:selected, boolean)
end
... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/helpers/autocomplete_helper.rb | Ruby | mit | 46 | master | 1,145 | # encoding: utf-8
module Web
module AutocompleteHelper
def set_feature_autocomplete
@features = Feature.all.sort do |a, b|
a.label.downcase <=> b.label.downcase
end
@feature_autocomplete = @features.map do |p|
{name: p.label, value: p.label }
end.to_json
end
def s... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/helpers/deploy_helper.rb | Ruby | mit | 46 | master | 2,343 | # encoding: utf-8
module Web
module DeployHelper
### href
def agent_href(host, opts = {})
query = opts.dup.tap {|q| q['host'] = host }.to_query
"/web/pipework/agent.conf?#{query}"
end
def worker_href(hostport, opts = {})
query = opts.dup.tap {|q| q['hostport'] = hostport }.to_query... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/helpers/resource_helper.rb | Ruby | mit | 46 | master | 2,283 | # encoding: utf-8
module Web
module ResourceHelper
def success_message(value=params['s'])
case value
when '1'
'Created.'
when '2'
'Updated.'
when '3'
'Deleted.'
when '4'
'Duplicated.'
when '5'
'Disabled.'
when '6'
'Enabled.... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/pipework_controller.rb | Ruby | mit | 46 | master | 1,844 | # encoding: utf-8
module Web
class PipeworkController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'pipework')
set :layout, './layout'
mime_type :text, 'text/plain'
before do
set_configurer
set_commander
end
get '/' do
end
error 404 ... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/irc_controller.rb | Ruby | mit | 46 | master | 1,575 | # encoding: utf-8
module Web
class IrcController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'irc')
set :layout, './layout'
before do
set_ircs
set_tab :irc
end
# I was ever a REST votary, but ...
get '/' do
herb :index
end
get... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/role_controller.rb | Ruby | mit | 46 | master | 1,973 | # encoding: utf-8
module Web
class RoleController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'role')
set :layout, './layout'
before do
set_roles
set_tab :role
end
# I was ever a REST votary, but ...
get '/' do
herb :index
end
... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/visualizer_controller.rb | Ruby | mit | 46 | master | 3,205 | # encoding: utf-8
module Web
class VisualizerController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'visualizer')
set :layout, './layout'
include ::Web::DeployHelper
before do
set_visualizers
set_role_autocomplete
set_irc_autocomplete
set... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/notifier_controller.rb | Ruby | mit | 46 | master | 3,057 | # encoding: utf-8
module Web
class NotifierController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'notifier')
set :layout, './layout'
include ::Web::DeployHelper
before do
set_notifiers
set_role_autocomplete
set_irc_autocomplete
set_email... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/resource_controller.rb | Ruby | mit | 46 | master | 963 | # encoding: utf-8
module Web
class ResourceController < Sinatra::Base
include SinatraHelper
register Sinatra::Rendering
register Sinatra::Reloader if Bootloader.development?
use Rack::MethodOverride
use ::Web::RequestLogger, $logger
set :sessions, true
set :public_folder, File.dirname(__F... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/email_controller.rb | Ruby | mit | 46 | master | 1,762 | # encoding: utf-8
module Web
class EmailController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'email')
set :layout, './layout'
before do
set_emails
set_tab :email
end
# I was ever a REST votary, but ...
get '/' do
herb :index
end
... |
github | sonots/haikanko | https://github.com/sonots/haikanko | web/controllers/front_controller.rb | Ruby | mit | 46 | master | 548 | # encoding: utf-8
module Web
class FrontController < ResourceController
set :views, File.join(File.dirname(__FILE__), '..', 'views', 'front')
set :layout, '../layouts/plain'
get '/' do
herb :frontpage
end
# from search form
get '/feature' do
redirect '/' unless label = params['l... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/host.rb | Ruby | mit | 46 | master | 423 | # encoding: utf-8
class Host < Resource
include Mongoid::Document
include Mongoid::Timestamps
has_and_belongs_to_many :features, class_name: 'Feature'
field :label, type: String
index({label: 1}, {unique: true})
validates_presence_of :label
validates_uniqueness_of :label
def self.makes(hosts)
Ar... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/resource.rb | Ruby | mit | 46 | master | 1,078 | # encoding: utf-8
class Resource
def self.readonly?
false
end
def new?
created_at.nil?
end
def error?
! valid?
end
def duplicate(params = {})
attributes = self.attributes.except("_id")
attributes.merge!(params)
if attributes["label"] and self.class.find_by(label: attributes["la... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/group_resource.rb | Ruby | mit | 46 | master | 294 | # encoding: utf-8
class GroupResource < Resource
def notify_updated
features.each {|f| f.updated_at = updated_at; f.save! } if !chained_update?
end
def chained_update?
stored = self.class.find(id)
stored.present? and (stored.feature_ids <=> self.feature_ids) != 0
end
end |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/history.rb | Ruby | mit | 46 | master | 1,594 | # encoding: utf-8
class History < Resource
include Mongoid::Document
include Haikanko::Helper
field :node_type, type: String, default: 'agent'
field :host, type: String
field :deployed_at, type: Time
class << self
def agent_deployed!(hosts)
set_deployed_at("agent", hosts, Time.now)
report_... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/email.rb | Ruby | mit | 46 | master | 581 | # encoding: utf-8
class Email < GroupResource
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
has_and_belongs_to_many :features, class_name: 'Feature'
field :label, type: String, default: 'arbitrary_label'
field :email_to, type: String
# field :message, type: String
in... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/visualizer.rb | Ruby | mit | 46 | master | 1,133 | # encoding: utf-8
class Visualizer < Feature
field :label, type: String, default: 'accesslog app_name'
field :format, type: String, default: '/^\[(?<time>[^\]]*)\] (?<pid>[^\t]*)\t(?<reqtime>[^\t]*)\t(?<device_id>[^\t]*)\t(?<app_id>[^\t]*)\t(?<viewer_id>[^\t]*)\t(?<owner_id>[^\t]*)\t(?<status>[^\t]*)\t(?<method>[^... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/notifier.rb | Ruby | mit | 46 | master | 862 | # encoding: utf-8
class Notifier < Feature
field :label, type: String, default: 'syslog warn app_name'
field :regexp, type: String, default: 'warn'
field :exclude, type: String
field :count_interval, type: Integer, default: 300
field :threshold, type: Integer, default: 1
# field :ignore_case, type: Boolean... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/irc.rb | Ruby | mit | 46 | master | 564 | # encoding: utf-8
class Irc < GroupResource
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
has_and_belongs_to_many :features, class_name: 'Feature'
field :label, type: String, default: 'arbitrary_label'
field :channel, type: String
field :staff, type: String
index({la... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/boot.rb | Ruby | mit | 46 | master | 236 | # encoding: utf-8
require_relative '../boot'
Bootloader.load_mongoid
require_relative 'resource'
require_relative 'group_resource'
require_relative 'feature'
Bootloader.load_dir('models')
Mongoid.logger = nil # turn off mongoid logger |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/feature.rb | Ruby | mit | 46 | master | 4,359 | # encoding: utf-8
class Feature < Resource
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
include ActiveModel::Translation
field :label, type: String, default: 'syslog warn app_name'
has_and_belongs_to_many :roles, class_name: 'Role'
has_and_belongs_to_many :hosts, class... |
github | sonots/haikanko | https://github.com/sonots/haikanko | models/role.rb | Ruby | mit | 46 | master | 820 | # encoding: utf-8
class Role < GroupResource
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Paranoia
has_and_belongs_to_many :features, class_name: 'Feature'
field :label, type: String, default: 'arbitrary_label'
field :hosts, type: Array
index({label: 1}, {unique: true})
vali... |
github | sonots/haikanko | https://github.com/sonots/haikanko | config/deploy.rb | Ruby | mit | 46 | master | 261 | # encoding: utf-8
require_relative '../pipework/boot'
# For help in making your deploy script, see the Mina documentation:
#
# - http://nadarei.co/mina
# - http://nadarei.co/mina/tasks
# - http://nadarei.co/mina/settings
# - http://nadarei.co/mina/helpers |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/boot.rb | Ruby | mit | 46 | master | 564 | # encoding: utf-8
require_relative '../boot'
Bundler.require(:default, :pipework)
require 'mina'
require 'mina/bundler'
require 'mina/rails'
require 'mina/git'
require 'mina/rbenv'
Bootloader.load_dir('pipework')
Bootloader.load_dir('pipework/lib')
Bootloader.load_dir('pipework/mina')
set :user, ENV['USER'] if ENV['U... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/Gemfile | Ruby | mit | 46 | master | 637 | source 'https://rubygems.org'
gem 'fluentd'
gem 'fluent-plugin-mongo'
gem 'bson_ext'
gem 'fluent-plugin-growthforecast'
#gem 'fluent-plugin-numeric-monitor'
gem 'fluent-plugin-mail'
gem 'fluent-plugin-datacounter'
gem 'fluent-plugin-groupcounter'
gem 'fluent-plugin-grepcounter'
gem 'fluent-plugin-file-alternative'
#ge... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/out_route.rb | Ruby | mit | 46 | master | 3,311 | #
# Fluent
#
# Copyright (C) 2011 FURUHASHI Sadayuki
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by a... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/out_hash_forward.rb | Ruby | mit | 46 | master | 2,659 | class Fluent::HashForwardOutput < Fluent::Output
Fluent::Plugin.register_output('hash_forward', self)
config_param :remove_prefix, :string, :default => nil
config_param :add_prefix, :string, :default => nil
def configure(conf)
super
if @remove_prefix
@removed_prefix_string = @remove_prefix + '.... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/out_ikachan.rb | Ruby | mit | 46 | master | 4,239 | class Fluent::IkachanOutput < Fluent::Output
Fluent::Plugin.register_output('ikachan', self)
config_param :host, :string
config_param :port, :integer, :default => 4979
config_param :channel, :string
config_param :message, :string, :default => nil
config_param :out_keys, :string, :default => ""
config_par... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/out_mail.rb | Ruby | mit | 46 | master | 4,492 | class Fluent::MailOutput < Fluent::Output
Fluent::Plugin.register_output('mail', self)
config_param :out_keys, :string, :default => ""
config_param :message, :string, :default => nil
config_param :message_out_keys, :string, :default => ""
config_param :time_key, :string, :default => nil
config_param :time_... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/in_dstat.rb | Ruby | mit | 46 | master | 3,183 | module Fluent
class DstatInput < Input
Plugin.register_input('dstat', self)
def initialize
super
require 'csv'
@hostname = `hostname -s`.chomp!
@line_number = 0
@first_keys = []
@second_keys = []
@data_array = []
@max_lines = 100
end
config_param :tag, :string
config_param ... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/fluentd/server/plugin/out_numeric_monitor.rb | Ruby | mit | 46 | master | 6,443 | class Fluent::NumericMonitorOutput < Fluent::Output
Fluent::Plugin.register_output('numeric_monitor', self)
EMIT_STREAM_RECORDS = 100
config_param :count_interval, :time, :default => 60
config_param :unit, :string, :default => nil
config_param :tag, :string, :default => 'monitor'
config_param :tag_prefix,... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/mina/worker.rb | Ruby | mit | 46 | master | 3,646 | # encoding: utf-8
if current_namespace == :worker
worker_opt_parse
end
def worker_opt_parse
hostports = []
if ENV['HOSTPORT']
hostports = ENV['HOSTPORT'].split(",")
else
hostports = FluentdConfig.workers
end
set :hostports, hostports
set :domain, hostports.map {|hostport| hostport.split(":")[0] ... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/mina/haikanko.rb | Ruby | mit | 46 | master | 3,037 | # encoding: utf-8
if current_namespace == :haikanko
set :user, ENV['USER'] if ENV['USER']
set :shared_paths, ['log']
set :deploy_to, HaikankoConfig.deploy_to || '$HOME/haikanko'
set :haikanko_root, "#{deploy_to}/current"
set :daemon_name, HaikankoConfig.daemon_name || 'haikanko'
set :repository, HaikankoCo... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/mina/list.rb | Ruby | mit | 46 | master | 1,603 | # encoding: utf-8
if current_namespace == :list
if ENV['ROLE']
set :roles, ENV['ROLE'].split(",")
end
end
desc 'Show all lists'
task :all do
features = roles.present? ? Feature.on_roles(roles) : Feature.all
puts features.map(&:label).join("\n")
end
desc 'Show all lists of notifiers'
task :notifier do
f... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/mina/agent.rb | Ruby | mit | 46 | master | 2,285 | # encoding: utf-8
if current_namespace == :agent
agent_opt_parse
agent_init_variables
end
def agent_opt_parse
hostnames = []
if ENV['LABEL']
hostnames = Feature.hostnames(ENV['LABEL'].split(","))
$stderr.puts 'LABEL does not exist' and exit unless hostnames.present?
elsif ENV['ROLE']
hostnames =... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/mina/cluster.rb | Ruby | mit | 46 | master | 421 | # encoding: utf-8
task :restart do
agent_hosts = Feature.all_hostnames
worker_hostports = FluentdConfig.workers
agent_hosts.each do |domain|
invoke_block(domain) { agent_stop }
end
worker_hostports.each do |hostport|
domain = hostport.split(":")[0]
invoke_block(domain) { worker_restart(hostport)... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/lib/mina_helper.rb | Ruby | mit | 46 | master | 6,561 | # encoding: utf-8
require 'tempfile'
def localhost
`hostname`.chomp
end
def files_dir
File.expand_path(APP_ROOT + '/pipework/files')
end
def templates_dir
File.expand_path(APP_ROOT + '/pipework/templates')
end
def fluentd_dir
File.expand_path(APP_ROOT + '/pipework/fluentd')
end
def mina_dir
File.expand_p... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/lib/configurer.rb | Ruby | mit | 46 | master | 962 | # encoding: utf-8
require 'tilt'
module Pipework
class NotFound < StandardError; end
end
module Pipework
class Configurer
def agent(hostname)
raise NotFound if hostname.nil?
features = Feature.on_hostnames(hostname).select {|f| f.enabled? and f.deployable? }
herb "agent", locals: {
f... |
github | sonots/haikanko | https://github.com/sonots/haikanko | pipework/lib/commander.rb | Ruby | mit | 46 | master | 1,648 | # encoding: utf-8
require 'dropkick'
module Pipework
class Commander
%w(deploy remove update restart start stop status).each do |action|
define_method("agent_#{action}") do |params|
command = mina_command("agent", action, params)
result = execute(command)
[command, result]
end... |
github | ankane/mittens | https://github.com/ankane/mittens | Rakefile | Ruby | bsd-3-clause | 46 | master | 550 | require "bundler/gem_tasks"
require "rake/testtask"
require "rake/extensiontask"
require "ruby_memcheck"
test_config = lambda do |t|
t.pattern = "test/**/*_test.rb"
end
Rake::TestTask.new(&test_config)
namespace :test do
RubyMemcheck::TestTask.new(:valgrind, &test_config)
end
task default: :test
Rake::Extension... |
github | ankane/mittens | https://github.com/ankane/mittens | mittens.gemspec | Ruby | bsd-3-clause | 46 | master | 741 | require_relative "lib/mittens/version"
Gem::Specification.new do |spec|
spec.name = "mittens"
spec.version = Mittens::VERSION
spec.summary = "Stemming for Ruby, powered by Snowball"
spec.homepage = "https://github.com/ankane/mittens"
spec.license = "BSD-3-Clause"
spec.autho... |
github | ankane/mittens | https://github.com/ankane/mittens | test/stemmer_test.rb | Ruby | bsd-3-clause | 46 | master | 887 | require_relative "test_helper"
class TestStemmer < Minitest::Test
def test_works
stemmer = Mittens::Stemmer.new
assert_equal "tomato", stemmer.stem("tomatoes")
assert_equal "consign", stemmer.stem("consignment")
end
def test_nil
stemmer = Mittens::Stemmer.new
assert_raises(TypeError) do
... |
github | ankane/mittens | https://github.com/ankane/mittens | ext/mittens/extconf.rb | Ruby | bsd-3-clause | 46 | master | 583 | require "mkmf"
require "open3"
vendor = File.expand_path("../../vendor/snowball", __dir__)
# CFLAGS from vendor/snowball/GNUmakefile and -fPIC
cflags = "-O2 -W -Wall -Wmissing-prototypes -Wmissing-declarations -fPIC"
make_cmd = RbConfig::CONFIG["host_os"] =~ /bsd|dragonfly/i ? "gmake" : "make"
output, status = Open3.... |
github | fog/fog-core | https://github.com/fog/fog-core | fog-core.gemspec | Ruby | mit | 46 | master | 1,817 | # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "fog/core/version"
Gem::Specification.new do |spec|
spec.name = "fog-core"
spec.version = Fog::Core::VERSION
spec.authors = ["Evan Light", "Wesley Beary"]
s... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/compute_spec.rb | Ruby | mit | 46 | master | 2,228 | require "spec_helper"
module Fog
module Compute
def self.require(*_args); end
end
end
describe "Fog::Compute" do
describe "#new" do
module Fog
module TheRightWay
class Compute
def initialize(_args); end
end
end
end
module Fog
module TheRightWay
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/mocking_spec.rb | Ruby | mit | 46 | master | 1,869 | require "spec_helper"
describe "Fog mocking" do
before do
@fog_was_mocked = Fog.mock?
Fog.unmock! if @fog_was_mocked
end
after do
Fog.mock! if @fog_was_mocked
end
describe "Fog.mock!" do
it "Fog.mock! returns true" do
assert_equal true, Fog.mock!
end
it "Fog.mock? without Fog... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/service_spec.rb | Ruby | mit | 46 | master | 6,271 | require "spec_helper"
describe Fog::Service do
class TestService < Fog::Service
requires :generic_api_key
recognizes :generic_user
class Real
attr_reader :options
def initialize(opts = {})
@options = opts
end
end
class Mock
attr_reader :options
def initia... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/spec_helper.rb | Ruby | mit | 46 | master | 343 | # Set home outside of real user
require "tmpdir"
ENV["HOME"] = Dir.mktmpdir("foghome")
require "minitest/autorun"
require "minitest/mock"
require "minitest/spec"
require "minitest/stub_const"
$LOAD_PATH.unshift "lib"
require "fog/core"
Dir["spec/fake_app/**/*.rb"].each do |file|
require File.join(File.dirname(__FI... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/storage_spec.rb | Ruby | mit | 46 | master | 2,622 | require "spec_helper"
module Fog
module Storage
def self.require(*_args); end
end
end
describe "Fog::Storage" do
describe "#new" do
module Fog
module TheRightWay
class Storage
def initialize(_args); end
end
end
end
module Fog
module TheRightWay
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/current_machine_spec.rb | Ruby | mit | 46 | master | 839 | require "spec_helper"
describe Fog::CurrentMachine do
before do
@was_mocking = Fog.mock?
Fog.mock!
@old_excon_defaults_mock = Excon.defaults[:mock]
Excon.defaults[:mock] = true
end
after do
Fog.unmock! unless @was_mocking
Fog::CurrentMachine.ip_address = nil
Excon.stubs.clear
E... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/fog_attribute_spec.rb | Ruby | mit | 46 | master | 20,898 | require "spec_helper"
class Service
def single_associations
FogSingleAssociationCollection.new
end
def multiple_associations
FogMultipleAssociationsCollection.new
end
end
class FogSingleAssociationModel < Fog::Model
identity :id
attribute :name, type: :string
end
class FogMultipleAssociationsM... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/timeout_spec.rb | Ruby | mit | 46 | master | 330 | require "spec_helper"
describe "Fog#timeout" do
before do
@old_timeout = Fog.timeout
end
after do
Fog.timeout = @old_timeout
end
it "defaults to 600" do
assert_equal 600, Fog.timeout
end
it "can be reassigned through Fog#timeout=" do
Fog.timeout = 300
assert_equal 300, Fog.timeout
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/identity_spec.rb | Ruby | mit | 46 | master | 2,263 | require "spec_helper"
module Fog
module Identity
def self.require(*_args); end
end
end
describe "Fog::Identity" do
describe "#new" do
module Fog
module TheRightWay
class Identity
def initialize(_args); end
end
end
end
module Fog
module TheRightWay
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/wait_for_spec.rb | Ruby | mit | 46 | master | 755 | require "spec_helper"
describe "Fog#wait_for" do
it "returns a Hash indicating the wait duration if successful" do
assert_equal({ duration: 0 }, Fog.wait_for(1) { true })
end
it "raises if the wait timeout is exceeded" do
assert_raises(Fog::Errors::TimeoutError) do
Fog.wait_for(2) { false }
en... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/credentials_spec.rb | Ruby | mit | 46 | master | 2,476 | require "spec_helper"
describe "credentials" do
before do
@old_home = ENV["HOME"]
@old_rc = ENV["FOG_RC"]
@old_credential = ENV["FOG_CREDENTIAL"]
@old_credentials = Fog.credentials
Fog.instance_variable_set("@credential_path", nil) # kill memoization
Fog.instance_variable_set("@credential",... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/utils_spec.rb | Ruby | mit | 46 | master | 1,023 | require "spec_helper"
describe Fog::Core::Utils do
describe "prepare_service_settings" do
it "changes String keys to be Symbols" do
settings = { "a" => 3 }
expected = { a: 3 }
assert_equal expected, Fog::Core::Utils.prepare_service_settings(settings)
end
it "leaves Symbol keys unchange... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/formatador_spec.rb | Ruby | mit | 46 | master | 3,378 | require "spec_helper"
describe Fog::Formatador do
describe "when object is Fog::Collection instance" do
before do
@member_class = Class.new(Fog::Model) do
attribute :name
def self.name
"MemberGadget"
end
end
@collection_class = Class.new(Fog::Collection) do
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/uuid_spec.rb | Ruby | mit | 46 | master | 264 | require "spec_helper"
describe "Fog::UUID" do
it "#supported?" do
Fog::UUID.supported? == SecureRandom.respond_to?(:uuid)
end
it "generates a valid UUID" do
Fog::UUID.uuid =~ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/
end
end |
github | fog/fog-core | https://github.com/fog/fog-core | spec/connection_spec.rb | Ruby | mit | 46 | master | 3,201 | require "spec_helper"
describe Fog::Core::Connection do
it "raises ArgumentError when no arguments given" do
assert_raises(ArgumentError) do
Fog::Core::Connection.new
end
end
[:request, :reset].each do |method|
it "responds to #{method}" do
connection = Fog::Core::Connection.new("http://... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/compute/models/server_spec.rb | Ruby | mit | 46 | master | 7,694 | require "spec_helper"
require "fog/compute/models/server"
describe Fog::Compute::Server do
before do
@server = Fog::Compute::Server.new
end
describe "#sshable?" do
describe "when the server is not ready" do
it "is false" do
@server.stub(:ready?, false) do
refute @server.sshable?
... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/core/whitelist_keys_spec.rb | Ruby | mit | 46 | master | 927 | require "spec_helper"
describe "Fog::WhitelistKeys" do
describe ".whitelist" do
describe "when other keys are present" do
it "returns Hash with only allowed keys" do
input = { name: "name", type: "type", size: 80 }
valid_keys = %w(name size)
output = Fog::WhitelistKeys.whitelist(in... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/core/collection_spec.rb | Ruby | mit | 46 | master | 501 | require "spec_helper"
require "securerandom"
class FogTestModelForCollection < Fog::Model
identity :id
end
class FogTestCollection < Fog::Collection
model FogTestModelForCollection
def all
self
end
end
describe Fog::Collection do
describe "array delegation" do
it "delegates methods with keywords t... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/core/model_spec.rb | Ruby | mit | 46 | master | 1,527 | require "spec_helper"
require "securerandom"
class FogTestModel < Fog::Model
identity :id
attribute :value
def create
self.identity = SecureRandom.hex
self
end
def update
self.value = 42
self
end
end
describe Fog::Model do
describe "#==" do
it "is not equal if one is not a Fog::Mo... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/core/stringify_keys_spec.rb | Ruby | mit | 46 | master | 978 | require "spec_helper"
describe "Fog::StringifyKeys" do
describe ".stringify" do
describe "when key is a Symbol" do
it "replaces key with String" do
input = { key: "value" }
output = Fog::StringifyKeys.stringify(input)
assert(output.key?("key"))
end
end
describe "when ... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/core/cache_spec.rb | Ruby | mit | 46 | master | 6,728 | require "spec_helper"
require "securerandom"
module Fog
class SubFogTestModel < Fog::Model
identity :id
attribute :config
attribute :subconfig
def initialize(new_attributes = {})
super
# This way we make YAML to use aliases
self.config = {
"users" => [
{ "user1... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/fake_app/fake_service.rb | Ruby | mit | 46 | master | 328 | class FakeService < Fog::Service
class Real
def initialize(_options)
end
end
class Mock
def initialize(_options)
end
end
model_path File.join(File.dirname(__FILE__), "models")
model :model
collection :collection
request_path File.join(File.dirname(__FILE__), "requests")
request :req... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/test_helpers/formats_helper_spec.rb | Ruby | mit | 46 | master | 4,078 | require "spec_helper"
require "fog/test_helpers/formats_helper"
require "fog/test_helpers/types_helper"
module Shindo
class Tests
def test(_str, &_block)
yield
end
end
end
describe "formats_helper" do
let(:shindo) { Shindo::Tests.new }
it "comparing welcome data against schema" do
data = { ... |
github | fog/fog-core | https://github.com/fog/fog-core | spec/test_helpers/schema_validator_spec.rb | Ruby | mit | 46 | master | 3,845 | require "spec_helper"
require "fog/test_helpers/formats_helper"
require "fog/schema/data_validator"
describe "SchemaValidator" do
let(:validator) { Fog::Schema::DataValidator.new }
describe "#validate" do
it "returns true when value matches schema expectation" do
assert validator.validate({ "key" => "Va... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/dns.rb | Ruby | mit | 46 | master | 289 | module Fog
module DNS
extend Fog::ServicesMixin
def self.zones
zones = []
providers.each do |provider|
begin
zones.concat(self[provider].zones)
rescue # ignore any missing credentials/etc
end
end
zones
end
end
end |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/compute.rb | Ruby | mit | 46 | master | 1,516 | module Fog
module Compute
extend Fog::ServicesMixin
def self.new(orig_attributes)
attributes = orig_attributes.dup # prevent delete from having side effects
provider = attributes.delete(:provider).to_s.downcase.to_sym
case provider
when :rackspace
version = attributes.delete(... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/test_helpers.rb | Ruby | mit | 46 | master | 526 | # So downstream users can use the test_helpers
require "fog/test_helpers/helper"
require "fog/test_helpers/collection_helper"
require "fog/test_helpers/formats_helper"
require "fog/test_helpers/mock_helper"
require "fog/test_helpers/model_helper"
require "fog/test_helpers/responds_to_helper"
require "fog/test_helpers/... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/core.rb | Ruby | mit | 46 | master | 3,195 | # external core dependencies
require "cgi"
require "uri"
require "excon"
require "fileutils"
require "formatador"
require "openssl"
require "time"
require "timeout"
require "ipaddr"
# internal core dependencies
require File.expand_path("core/version", __dir__)
# Mixins
require File.expand_path("core/services_mixin", ... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/storage.rb | Ruby | mit | 46 | master | 1,536 | begin
# Use mime/types/columnar if available, for reduced memory usage
require "mime/types/columnar"
rescue LoadError
require "mime/types"
end
module Fog
module Storage
extend Fog::ServicesMixin
def self.directories
directories = []
providers.each do |provider|
begin
dire... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/formatador.rb | Ruby | mit | 46 | master | 2,381 | module Fog
# Fog::Formatador
module Formatador
PARSE_REGEX = ::Formatador::PARSE_REGEX
STYLES = ::Formatador::STYLES
INDENT_REGEX = ::Formatador::INDENT_REGEX
def self.formatador
Thread.current[:formatador] ||= ::Formatador.new
end
def self.format(object, opts = { include_n... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/core/service.rb | Ruby | mit | 46 | master | 10,142 | require "fog/core/utils"
module Fog
def self.services
@services ||= {}
end
class Service
class Error < Fog::Errors::Error; end
class NotFound < Fog::Errors::NotFound; end
module NoLeakInspector
def inspect
"#<#{self.class}:#{object_id} #{(instance_variables - service.secrets).map ... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/core/logger.rb | Ruby | mit | 46 | master | 1,219 | module Fog
class Logger
@channels = {
deprecation: ::STDERR,
warning: ::STDERR
}
@channels[:debug] = ::STDERR if ENV["DEBUG"]
# provide an env var with narrower scope in case of namespace conflicts
@channels[:debug] = ::STDERR if ENV["FOG_DEBUG"]
def self.[](channel)
@chan... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/core/wait_for_defaults.rb | Ruby | mit | 46 | master | 847 | module Fog
@interval = lambda { |retries| [2**(retries - 1), @max_interval].min }
class << self
attr_reader :interval
end
def self.interval=(interval)
if interval.is_a?(Proc)
raise ArgumentError, "interval proc must return a positive" unless interval.call(1) >= 0
else
raise ArgumentErr... |
github | fog/fog-core | https://github.com/fog/fog-core | lib/fog/core/connection.rb | Ruby | mit | 46 | master | 4,760 | module Fog
module Core
# Fog::Core::Connection is a generic class to contain a HTTP link to an API.
#
# It is intended to be subclassed by providers who can then add their own
# modifications such as authentication or response object.
#
class Connection
class << self
@@user_agen... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.