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
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/mailers/rails/assessment/lead_notification_mailer.rb
Ruby
mit
48
main
583
module Rails module Assessment class LeadNotificationMailer < ApplicationMailer def new_lead(response, notification_email) @response = response @user_email = response.answers.dig("lead", "email") @user_name = response.answers.dig("lead", "name") @assessment_slug = response.as...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/helpers/rails/assessment/application_helper.rb
Ruby
mit
48
main
2,968
require "uri" require "cgi" module Rails module Assessment module ApplicationHelper include Rails::Assessment::Engine.routes.url_helpers # Provide default URL options for route helpers def default_url_options {} end # Safely access nested payload data from a result rule ...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/models/rails/assessment/response.rb
Ruby
mit
48
main
1,108
require "securerandom" module Rails module Assessment class Response < ApplicationRecord self.table_name = "rails_assessment_responses" before_validation :ensure_uuid, on: :create store_accessor :answers if respond_to?(:store_accessor) validates :assessment_slug, presence: true v...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/controllers/rails/assessment/responses_controller.rb
Ruby
mit
48
main
2,998
module Rails module Assessment class ResponsesController < ApplicationController before_action :load_definition def create builder = Rails::Assessment::ResponseBuilder.new(@definition) answers = builder.build(response_params) missing = @definition.questions.select(&:required?...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/controllers/rails/assessment/assessments_controller.rb
Ruby
mit
48
main
1,741
module Rails module Assessment class AssessmentsController < ApplicationController before_action :load_definition def show @response = Response.new(assessment_slug: @definition.slug) @theme = theme_resolver.resolve(request: request, overrides: @definition.theme) end def r...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/controllers/rails/assessment/application_controller.rb
Ruby
mit
48
main
295
module Rails module Assessment class ApplicationController < ActionController::Base layout "rails/assessment/application" protect_from_forgery with: :exception helper Rails::Assessment::ApplicationHelper helper Rails::Assessment::Theme::Helpers end end end
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
app/services/rails/assessment/webhook_service.rb
Ruby
mit
48
main
1,679
require "net/http" require "json" module Rails module Assessment class WebhookService def self.post_lead(response, webhook_url) new(response, webhook_url).call end def initialize(response, webhook_url) @response = response @webhook_url = webhook_url end def...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/test_helper.rb
Ruby
mit
48
main
791
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require_relative "../test/dummy/config/environment" ActiveRecord::Migrator.migrations_paths = [ File.expand_path("../test/dummy/db/migrate", __dir__) ] ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__) require "rails/test_help"...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/lib/rails/assessment/definition_test.rb
Ruby
mit
48
main
4,660
require "test_helper" module Rails module Assessment class DefinitionTest < ActiveSupport::TestCase test "initializes with notification_email" do definition = Definition.new(notification_email: "leads@example.com") assert_equal "leads@example.com", definition.notification_email end ...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/lib/rails/assessment/logic_engine_test.rb
Ruby
mit
48
main
1,127
require "test_helper" module Rails module Assessment class LogicEngineTest < ActiveSupport::TestCase def setup @rules = [ ResultRule.new(text: "Match", all_tags: %w[wifi_ok]), ResultRule.new(text: "Match two", any_tags: %w[wifi_bad]), ResultRule.new(text: "Fallback", f...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/lib/rails/assessment/response_builder_test.rb
Ruby
mit
48
main
1,867
require "test_helper" module Rails module Assessment class ResponseBuilderTest < ActiveSupport::TestCase def setup @definition = Definition.new( slug: "demo", questions: [ Question.from_hash( id: "wifi", text: "Wifi?", option...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/lib/rails/assessment/dsl_loader_test.rb
Ruby
mit
48
main
2,367
require "test_helper" require "tmpdir" require "fileutils" module Rails module Assessment class DslLoaderTest < ActiveSupport::TestCase def setup @original_paths = Rails::Assessment.configuration.assessments_paths @tmpdir = Dir.mktmpdir("assessments") Rails::Assessment.configuration...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/lib/rails/assessment/configuration_test.rb
Ruby
mit
48
main
1,560
require "test_helper" module Rails module Assessment class MockRequest def initialize(params = {}) @params = params end def params @params end def query_parameters @params end def request_parameters {} end def path_paramete...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/services/rails/assessment/webhook_service_test.rb
Ruby
mit
48
main
6,264
require "test_helper" module Rails module Assessment class WebhookServiceTest < ActiveSupport::TestCase setup do @response = Response.create!( assessment_slug: "test-assessment", answers: { "lead" => { "name" => "John Doe", "email" => "joh...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/integration/lead_capture_test.rb
Ruby
mit
48
main
10,604
require "test_helper" class LeadCaptureTest < ActionDispatch::IntegrationTest setup do Rails::Assessment.registry.reset Rails::Assessment.define "lead-test" do title "Lead Capture Test" hook "Test lead capture" notification_email "leads@example.com" webhook_url "https://example.com/w...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/integration/navigation_test.rb
Ruby
mit
48
main
2,187
require "test_helper" class NavigationTest < ActionDispatch::IntegrationTest setup do Rails::Assessment.registry.reset Rails::Assessment.define "layout-check" do title "Layout Check" hook "Ensure engine layout renders." question "Ready?" do option "Yes", tag: :yes end en...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/dummy/db/schema.rb
Ruby
mit
48
main
1,334
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
hmontazeri/rails-assessment
https://github.com/hmontazeri/rails-assessment
test/mailers/rails/assessment/lead_notification_mailer_test.rb
Ruby
mit
48
main
3,166
require "test_helper" module Rails module Assessment class LeadNotificationMailerTest < ActionMailer::TestCase setup do @response = Response.create!( assessment_slug: "test-assessment", answers: { "lead" => { "name" => "John Doe", "email" ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
protokoll.gemspec
Ruby
mit
48
master
921
$:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "protokoll/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "protokoll" s.version = Protokoll::VERSION s.authors = ["Celso Dantas"] s.email = ["celsodantas@...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
Gemfile
Ruby
mit
48
master
525
source "http://rubygems.org" # Declare your gem's dependencies in protocol_number_plugin.gemspec. # Bundler will treat runtime dependencies like base dependencies, and # development dependencies will be added by default to the :development group. gemspec # Declare any dependencies that are still in development here i...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
Rakefile
Ruby
mit
48
master
703
#!/usr/bin/env rake begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end begin require 'rdoc/task' rescue LoadError require 'rdoc/rdoc' require 'rake/rdoctask' RDoc::Task = Rake::RDocTask end RDoc::Task.new(:rdoc) do |rdoc| rdoc.r...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/generators/protokoll/migration/scope_by_generator.rb
Ruby
mit
48
master
718
require 'rails/generators' module Protokoll module Generators module Migration class ScopeByGenerator < ::Rails::Generators::Base include Rails::Generators::Migration desc "Generate protokoll's scope_by migration" def create_migration_file migration_name = "add_scope_by_...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/generators/protokoll/migration/migration_generator.rb
Ruby
mit
48
master
662
require 'rails/generators' module Protokoll module Generators class MigrationGenerator < ::Rails::Generators::Base include Rails::Generators::Migration desc "Generate protokoll migration" def create_migration_file migration_name = "create_custom_auto_increments.rb" ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/generators/protokoll/migration/templates/add_scope_by_to_custom_auto_increments.rb
Ruby
mit
48
master
469
class AddScopeByToCustomAutoIncrements < ActiveRecord::Migration def up add_column :custom_auto_increments, :counter_model_scope, :string add_index :custom_auto_increments, [:counter_model_name, :counter_model_scope], :unique => true, :name => :counter_model_name_scope end def down remo...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/generators/protokoll/migration/templates/create_custom_auto_increments.rb
Ruby
mit
48
master
362
class CreateCustomAutoIncrements < ActiveRecord::Migration def up create_table :custom_auto_increments, :force => true do |t| t.string :counter_model_name t.integer :counter, :default => 0 t.timestamps end add_index :custom_auto_increments, :counter_model_name end def down dro...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/protokoll/counter.rb
Ruby
mit
48
master
1,484
# frozen_string_literal: true require 'active_record' module Protokoll class Counter def self.next(object, options) element = Models::CustomAutoIncrement.find_or_create_by(build_attrs(object, options)) element.counter = options[:start] if outdated?(element, options) || element.counter == 0 el...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/protokoll/formater.rb
Ruby
mit
48
master
1,960
# frozen_string_literal: true module Protokoll class Formater def format(number, options) @options = options build(number) end private # gets the next number. # it prepends the prefix + counter + sufix # ex: # "%Y####BANK" # %Y => prefix (year) # #### => count...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
lib/protokoll/protokoll.rb
Ruby
mit
48
master
1,222
module Protokoll extend ActiveSupport::Concern module ClassMethods # Class method available in models # # == Example # class Order < ActiveRecord::Base # protokoll :number # end # def protokoll(column, _options = {}) options = { :pattern => "%Y%m#####", ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/protokoll_test.rb
Ruby
mit
48
master
11,685
require 'test_helper' class ProtokollTest < ActiveSupport::TestCase def setup time = Time.local(2011, 9, 25, 12, 0, 0) Timecop.travel(time) end def teardown reset_models end def reset_models ProtokollTest.send(:remove_const, 'Protocol') if defined? Protocol ProtokollTest.send(:remove_c...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/test_helper.rb
Ruby
mit
48
master
328
# Configure Rails Environment ENV["RAILS_ENV"] = "test" require File.expand_path("../dummy/config/environment.rb", __FILE__) require "rails/test_help" require 'rubygems' require "timecop" Rails.backtrace_cleaner.remove_silencers! # Load support files Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| requ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/app/models/call_defined_in_tests.rb
Ruby
mit
48
master
248
# As I need to change the class a lot, I'm defining (and redefining tons of times) # in the tests files. # I'm just keeping the model here to make easy to understand what models # are been used in the test. # class Call < ActiveRecord::Base # end
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/app/models/protocol_defined_in_tests.rb
Ruby
mit
48
master
253
# As I need to change the class a lot, I'm defining (and redefining tons of times) # in the tests files. # I'm just keeping the model here to make easy to understand what models # are been used in the test. # class Protocol < ActiveRecord::Base # end
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/db/schema.rb
Ruby
mit
48
master
1,623
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # This file is the source Rails uses to define your schema when running `bin/rai...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/db/migrate/20110923024431_create_protocols.rb
Ruby
mit
48
master
212
class CreateProtocols < ActiveRecord::Migration[4.2] def change create_table :protocols do |t| t.string :number t.string :context t.string :context_2 t.timestamps end end end
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/db/migrate/20120222164124_create_custom_auto_increments.rb
Ruby
mit
48
master
366
class CreateCustomAutoIncrements < ActiveRecord::Migration[4.2] def up create_table :custom_auto_increments, :force => true do |t| t.string :counter_model_name t.integer :counter, :default => 0 t.timestamps end add_index :custom_auto_increments, :counter_model_name end def down ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/db/migrate/20160310030821_add_scope_by_to_custom_auto_increments.rb
Ruby
mit
48
master
474
class AddScopeByToCustomAutoIncrements < ActiveRecord::Migration[4.2] def up add_column :custom_auto_increments, :counter_model_scope, :string add_index :custom_auto_increments, [:counter_model_name, :counter_model_scope], :unique => true, :name => :counter_model_name_scope end def down ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/application.rb
Ruby
mit
48
master
1,610
require File.expand_path('../boot', __FILE__) require 'rails/all' Bundler.require require "protokoll" module Dummy class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers ...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/routes.rb
Ruby
mit
48
master
1,788
Dummy::Application.routes.draw do # The priority is based upon order of creation: # first created -> highest priority. # Sample of regular route: # match 'products/:id' => 'catalog#view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # match 'product...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/environments/test.rb
Ruby
mit
48
master
1,661
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test su...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/environments/production.rb
Ruby
mit
48
master
1,739
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_c...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/environments/development.rb
Ruby
mit
48
master
870
Dummy::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web ser...
github
celsodantas/protokoll
https://github.com/celsodantas/protokoll
test/dummy/config/initializers/secret_token.rb
Ruby
mit
48
master
496
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
github
tomiwaAdey/Nimrod
https://github.com/tomiwaAdey/Nimrod
Nimrod.rb
Ruby
mit
48
master
7,663
#Nimrod #========================================== # Author: Tomiwa Adey # Date: 25th March 2017 # Title: Nimrod # Description: Nimrod is a bot that you can # employ to help you find the emails of # people you want to reach out to. # It does the research manually by signing into # several tools on your behalf and fi...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
super_cache.gemspec
Ruby
mit
48
master
800
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'super_cache/version' Gem::Specification.new do |gem| gem.name = "super_cache" gem.version = SuperCache::VERSION gem.authors = ["ShiningRay"] gem.email ...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
Rakefile
Ruby
mit
48
master
573
# encoding: UTF-8 require "bundler/gem_tasks" require 'rake/testtask' require 'rdoc/task' Rake::TestTask.new do |t| t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc "Run tests" task :default => :test desc 'Generate documentation for InheritedResources.' Rake::RDocTask.new(:rdoc) do |...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
Gemfile
Ruby
mit
48
master
215
source 'http://rubygems.org' #source 'http://ruby.taobao.org' # Specify your gem's dependencies in super_cache.gemspec gemspec gem 'rake' gem 'rails', '~> 3.1' gem 'memcache-client' #gem 'mocha', :require => false
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache.rb
Ruby
mit
48
master
1,033
require "super_cache/version" require 'uri' require 'fileutils' require 'super_cache/mem_cache_store_patch' # for static-caching the generated html pages module SuperCache autoload :Lock, 'super_cache/lock' autoload :DogPileFilter, 'super_cache/dog_pile_filter' autoload :SimpleFilter, 'super_cache/simp...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/cache_meta_info.rb
Ruby
mit
48
master
1,076
# To change this template, choose Tools | Templates # and open the template in the editor. module SuperCache module CacheMetaInfo autoload :RedisStore, 'super_cache/cache_meta_info/redis_store' autoload :MemCacheStore, 'super_cache/cache_meta_info/mem_cache_store' def key_for_cached_keys "#{self...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/lock.rb
Ruby
mit
48
master
1,200
module SuperCache class Lock class MaxRetriesError < RuntimeError; end DEFAULT_RETRY = 5 DEFAULT_EXPIRY = 30 class << self def synchronize(key, lock_expiry = DEFAULT_EXPIRY, retries = DEFAULT_RETRY) if recursive_lock?(key) yield else begin re...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/dog_pile_filter.rb
Ruby
mit
48
master
1,714
module SuperCache class DogPileFilter < SimpleFilter attr_accessor :flag_key def initialize(*args) super(*args) self.flag_key = "flag:#{cache_path}" end # 1. check the expiration info of target key # 2. if target key is expired, add a lock against target key # 2.1 if not expired, r...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/simple_filter.rb
Ruby
mit
48
master
2,585
module SuperCache class SimpleFilter def self.filter(options, controller, action) if controller.perform_caching new(options, controller, action).filter else action.call end end attr_accessor :options, :controller, :action, :cache_path, :content_type, :response, :request ...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/cache_meta_info/redis_store.rb
Ruby
mit
48
master
512
module SuperCache module CacheMetaInfo module RedisStore def append_cached_key(key) cached_keys << key end def clear_related_caches cached_keys.each do |key| Rails.cache.delete key cached_keys.delete key end end def remove_cached_key(key) cached_keys.delete key ...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
lib/super_cache/cache_meta_info/mem_cache_store.rb
Ruby
mit
48
master
423
module SuperCache module CacheMetaInfo module MemCacheStore def append_cached_key(key) cached_keys @need_append ||= !Rails.cache.write(key_for_cached_keys, key, :raw => true, :unless_exist => true ) Rails.cache.append(key_for_cached_keys, ",#{key}") i...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
test/cache_meta_info_test.rb
Ruby
mit
48
master
1,080
require File.expand_path('test_helper', File.dirname(__FILE__)) require File.expand_path('my_controller', File.dirname(__FILE__)) Rails.cache = ActiveSupport::Cache::MemCacheStore.new class Model include SuperCache::CacheMetaInfo include SuperCache::CacheMetaInfo::MemCacheStore attr_accessor :id def initialize(...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
test/super_cache_test.rb
Ruby
mit
48
master
1,333
require File.expand_path('test_helper', File.dirname(__FILE__)) require File.expand_path('my_controller', File.dirname(__FILE__)) class MyController super_caches_page :index end class SuperCacheTest < ActionController::TestCase tests MyController setup do MyController.counter = 0 end test "should get inde...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
test/test_helper.rb
Ruby
mit
48
master
1,177
require 'rubygems' require 'bundler' Bundler.setup require 'test/unit' #require 'mocha/setup' ENV["RAILS_ENV"] = "test" RAILS_ROOT = "anywhere" require "active_support" require "active_model" require "action_controller" I18n.load_path << File.join(File.dirname(__FILE__), 'locales', 'en.yml') I18n.reload! class Ap...
github
ShiningRay/super_cache
https://github.com/ShiningRay/super_cache
test/dog_pile_filter_test.rb
Ruby
mit
48
master
1,210
require File.expand_path('test_helper', File.dirname(__FILE__)) require File.expand_path('my_controller', File.dirname(__FILE__)) #Rails.cache = ActiveSupport::Cache::MemCacheStore.new class MyController super_caches_page :index, :lock => true end class DogPileFilterTest < ActionController::TestCase tests MyContro...
github
tpope/rails-default-database
https://github.com/tpope/rails-default-database
rails-default-database.gemspec
Ruby
mit
48
master
640
Gem::Specification.new do |s| s.name = "rails-default-database" s.version = "1.1.2" s.summary = "Make database.yml optional in Rails" s.description = "Provides a default database configuration for Rails applications that lack one" s.authors = ["Tim P...
github
tpope/rails-default-database
https://github.com/tpope/rails-default-database
lib/rails-default-database.rake
Ruby
mit
48
master
276
desc 'Write out config/database.yml from rails-default-database' task 'db:config' do contents = Rails.configuration.database_configuration.to_yaml File.open(Rails.root.join('config/database.yml'), 'w') do |f| f.puts contents.sub(/^---\n/, '').gsub(/%i/, '') end end
github
tpope/rails-default-database
https://github.com/tpope/rails-default-database
lib/rails-default-database.rb
Ruby
mit
48
master
2,647
Rails::Application::Configuration.class_eval do def environments_for_database_configuration ['development', 'test', 'production'] | root.join('config', 'environments').children.map do |e| e.basename('.rb').to_s if e.extname == '.rb' end.compact.sort end def database_configuration_with_de...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
aws-inventory.gemspec
Ruby
mit
48
master
1,380
# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "aws_inventory/version" Gem::Specification.new do |spec| spec.name = "aws-inventory" spec.version = AwsInventory::VERSION spec.authors = ["Tung Nguyen"] spec.email ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws-inventory.rb
Ruby
mit
48
master
989
$:.unshift(File.expand_path("../", __FILE__)) require "aws_inventory/version" require "text-table" require "active_support/all" module AwsInventory autoload :Base, "aws_inventory/base" autoload :Help, "aws_inventory/help" autoload :Command, "aws_inventory/command" autoload :CLI, "aws_inventory/cli" autoload ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/cfn.rb
Ruby
mit
48
master
1,276
class AwsInventory::Cfn < AwsInventory::Base ALL_STATUSES = %w[ REVIEW_IN_PROGRESS CREATE_FAILED UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_IN_PROGRESS CREATE_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS ROLLBACK_IN_PROGRESS DELETE_COMPLETE UPDATE_COMPLETE UPDATE_IN_PRO...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/base.rb
Ruby
mit
48
master
1,922
# Child class must implement this interface. # Methods: # header - header row to display. Array of strings. # data - data to display under header. 2D Array. # Each item in the array represents a row of data. class AwsInventory::Base include AwsInventory::AwsServices def initialize(options) @options = ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/ec2.rb
Ruby
mit
48
master
903
class AwsInventory::Ec2 < AwsInventory::Base def header ["Name", "Instance Id", "Instance Type", "Platform", "Security Groups"] end def data instances.map do |i| name = name_from_tag(i) group_names = security_group_names(i) [ name, i.instance_id, i.instance_type...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/help.rb
Ruby
mit
48
master
247
module AwsInventory::Help class << self def text(namespaced_command) path = namespaced_command.to_s.gsub(':','/') path = File.expand_path("../help/#{path}.md", __FILE__) IO.read(path) if File.exist?(path) end end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/aws_services.rb
Ruby
mit
48
master
794
require 'aws-sdk' module AwsInventory::AwsServices include AwsInventory::Shared def cfn @cfn ||= Aws::CloudFormation::Client.new end def ec2 @ec2 ||= Aws::EC2::Client.new end def pricing @pricing ||= Aws::Pricing::Client.new end def rds @rds ||= Aws::RDS::Client.new end def rou...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/route53.rb
Ruby
mit
48
master
627
class AwsInventory::Route53 < AwsInventory::Base def header ["Domain", "Record Set Count"] end def data zones.map do |zone| record_sets = resource_record_sets(zone) [zone.name, record_sets.count] end end def records zones.inject([]) do |array, zone| array << resource_record...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/keypair.rb
Ruby
mit
48
master
466
class AwsInventory::Keypair < AwsInventory::Base def header ["Key Name", "Instance Count"] end def data key_pairs.map do |key| instance_count = instance_count(key) [key.key_name, instance_count] end end def sort(data) data.sort_by { |i| i[1] }.reverse end def key_pairs ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/rds.rb
Ruby
mit
48
master
380
class AwsInventory::Rds < AwsInventory::Base autoload :Shared, "aws_inventory/rds/shared" autoload :Summary, "aws_inventory/rds/summary" autoload :Port, "aws_inventory/rds/port" # Default is the open report because it seems like the most useful report def report Summary.new(@options).report if show(:summ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/acm.rb
Ruby
mit
48
master
313
class AwsInventory::Acm < AwsInventory::Base def header ["Domain", "Cert Arn"] end def data certificate_summary_list.map do |cert| [cert.domain_name, cert.certificate_arn] end end def certificate_summary_list @summary ||= acm.list_certificates.certificate_summary_list end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/security_group.rb
Ruby
mit
48
master
530
class AwsInventory::SecurityGroup < AwsInventory::Base autoload :Shared, "aws_inventory/security_group/shared" autoload :Summary, "aws_inventory/security_group/summary" autoload :Open, "aws_inventory/security_group/open" autoload :Unused, "aws_inventory/security_group/unused" # Default is the open report bec...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/vpc.rb
Ruby
mit
48
master
1,105
class AwsInventory::Vpc < AwsInventory::Base def header ["Name", "Vpc ID", "CIDR", "Subnets", "Instances"] end def data vpcs.map do |vpc| subnets = subnets_for(vpc) instances = instances_in(subnets) [ vpc_name(vpc.vpc_id), vpc.vpc_id, vpc.cidr_block, sub...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/presenter.rb
Ruby
mit
48
master
580
class AwsInventory::Presenter autoload :Base, "aws_inventory/presenters/base" autoload :Tab, "aws_inventory/presenters/tab" autoload :Table, "aws_inventory/presenters/table" autoload :Json, "aws_inventory/presenters/json" def initialize(options, data) @options = options @data = data end def disp...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/shared.rb
Ruby
mit
48
master
337
module AwsInventory::Shared def instances return @instances if @instances @instances = [] resp = ec2.describe_instances resp.reservations.each do |res| @instances += res.instances end @instances end def security_groups @security_groups ||= ec2.describe_security_groups.security_...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/eb.rb
Ruby
mit
48
master
412
class AwsInventory::Eb < AwsInventory::Base def header ["Environment", "Application", "Solution Stack"] end def data eb_environments.map do |environment| [ environment.environment_name, environment.application_name, environment.solution_stack_name, ] end end d...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/command.rb
Ruby
mit
48
master
637
require "thor" module AwsInventory class Command < Thor class << self def dispatch(m, args, options, config) # Allow calling for help via: # aws-inventory command help # aws-inventory command -h # aws-inventory command --help # aws-inventory command -D ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/ecs.rb
Ruby
mit
48
master
253
class AwsInventory::Ecs < AwsInventory::Base autoload :Service, "aws_inventory/ecs/service" autoload :Cluster, "aws_inventory/ecs/cluster" # Override report def report Service.new(@options).report Cluster.new(@options).report end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/elb.rb
Ruby
mit
48
master
1,947
class AwsInventory::Elb < AwsInventory::Base def header ["ELB", "Type", "Security Group", "Open Ports"] end def data data = [] elbs.each do |lb| # lb.security_groups is actualy a list of group_ids lb.security_groups.each do |group_id| security_group_name = security_group_name(grou...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/cli.rb
Ruby
mit
48
master
1,996
module AwsInventory class CLI < Command class_option :verbose, type: :boolean class_option :header, default: true, type: :boolean desc "cfn", "report cfn inventory" long_desc Help.text(:cfn) def cfn Cfn.new(options).report end desc "ec2", "report ec2 inventory" long_desc Help.t...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/iam.rb
Ruby
mit
48
master
476
class AwsInventory::Iam < AwsInventory::Base autoload :Shared, "aws_inventory/iam/shared" autoload :Summary, "aws_inventory/iam/summary" autoload :User, "aws_inventory/iam/user" autoload :Group, "aws_inventory/iam/group" # Default is the groups report because it seems like the most useful report def report...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/cloudwatch.rb
Ruby
mit
48
master
864
require "action_view" class AwsInventory::Cloudwatch < AwsInventory::Base include ActionView::Helpers::DateHelper def header ["Alarm Name", "Threshold"] end def data alarms.map do |alarm| [ alarm.alarm_name, threshold_desc(alarm) ] end end def threshold_desc(alarm...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/rds/shared.rb
Ruby
mit
48
master
1,198
module AwsInventory::Rds::Shared # pretty name of vpc def vpc_name(db) group_ids = db.vpc_security_groups.map(&:vpc_security_group_id) resp = ec2.describe_security_groups(group_ids: group_ids) groups = resp.security_groups vpc_ids = groups.map(&:vpc_id) vpc_ids.map do |vpc_id| pretty_vpc_n...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/rds/summary.rb
Ruby
mit
48
master
486
class AwsInventory::Rds class Summary < AwsInventory::Base include Shared def header ["Name", "Engine", "Instance Class", "Publicly Accessible", "VPC", "Security Groups"] # end def data db_instances.map do |db| [ db.db_name, db.engine, db.db_in...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/rds/port.rb
Ruby
mit
48
master
1,402
class AwsInventory::Rds class Port < AwsInventory::Base include Shared def header ["RDS Db Name", "Security Group", "Range/Source", "Port"] end def data data = [] db_instances.each do |db| db_security_groups = vpc_security_groups(db) db_security_groups.each do |sg| ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/security_group/shared.rb
Ruby
mit
48
master
985
module AwsInventory::SecurityGroup::Shared def used_security_groups groups = instances.inject([]) do |results, i| results += i.security_groups # returns Aws::EC2::Types::GroupIdentifier results end instance_groups = groups.uniq(&:group_id) v1_group_ids = elbv1.describe_load_balancers.load...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/security_group/summary.rb
Ruby
mit
48
master
331
class AwsInventory::SecurityGroup class Summary < AwsInventory::Base include Shared def header ["Security Group", "Count"] end def data [ ["Total", security_groups.size], ["Used", used_security_groups.size], ["Unused", unused_security_groups.size], ] end...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/security_group/unused.rb
Ruby
mit
48
master
314
class AwsInventory::SecurityGroup class Unused < AwsInventory::Base include Shared def header ["Security Group Name", "Security Group Id"] end def data unused_security_groups.map do |sg| [ sg.group_name, sg.group_id ] end end end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/security_group/open.rb
Ruby
mit
48
master
1,848
require 'facets/array/arrange' class AwsInventory::SecurityGroup class Open < AwsInventory::Base include Shared def header ["Security Group", "Open to World"] end def data opened_security_groups_in_use = opened_security_groups.select do |sg| group_ids_in_use = used_security_grou...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/ecs/cluster.rb
Ruby
mit
48
master
483
class AwsInventory::Ecs::Cluster < AwsInventory::Base def header ["Cluster", "Container Instances", "Running Tasks"] end def data ecs_clusters.map do |cluster| [ cluster.cluster_name, cluster.registered_container_instances_count, cluster.running_tasks_count, ] end ...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/ecs/service.rb
Ruby
mit
48
master
794
class AwsInventory::Ecs::Service < AwsInventory::Base def header ["Service", "Cluster", "Running Tasks"] end def data ecs_services.map do |service| [ service.service_name, cluster_name(service.cluster_arn), service.running_count, ] end end def cluster_name(clu...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/presenters/json.rb
Ruby
mit
48
master
216
require "json" class AwsInventory::Presenter::Json < AwsInventory::Presenter::Base def display json_data = { header: data.shift, data: data } puts JSON.pretty_generate(json_data) end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/presenters/table.rb
Ruby
mit
48
master
208
require 'text-table' class AwsInventory::Presenter::Table < AwsInventory::Presenter::Base def display table = Text::Table.new table.head = data.shift table.rows = data puts table end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/presenters/base.rb
Ruby
mit
48
master
206
class AwsInventory::Presenter::Base def initialize(options, data) @options = options @data = data end def data @options[:header] ? @data : @data[1..-1] # remove the header row end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/iam/shared.rb
Ruby
mit
48
master
1,456
module AwsInventory::Iam::Shared def group_names(user) groups = groups_for(user) groups.map(&:group_name) end @@groups = {} def groups_for(user) return @@groups[user.user_name] if @@groups[user.user_name] @@groups[user.user_name] = iam.list_groups_for_user(user_name: user.user_name).groups e...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/iam/user.rb
Ruby
mit
48
master
374
class AwsInventory::Iam class User < AwsInventory::Base include Shared def header ["User", "Password Last Used"] end def data users.map do |user| group_names = group_names(user).join(',') [user.user_name, group_names] end end def sort(data) data.sort...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/iam/group.rb
Ruby
mit
48
master
485
class AwsInventory::Iam class Group < AwsInventory::Base include Shared def header ["Group Name", "User Count", "User Names"] end def data data = [["(groupless)", groupless_users.size, groupless_users.join(', ')]] data += groups.map do |group| group_users = users_in_group(g...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
lib/aws_inventory/iam/summary.rb
Ruby
mit
48
master
242
class AwsInventory::Iam class Summary < AwsInventory::Base include Shared def header ["Summary", "Count"] end def data [ ["Groups", groups.size], ["Users", users.size] ] end end end
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
spec/spec_helper.rb
Ruby
mit
48
master
469
ENV["TEST"] = "1" # Ensures aws api never called. Fixture home folder does not contain ~/.aws/credentails ENV['HOME'] = "spec/fixtures/home" # require "simplecov" # SimpleCov.start require "pp" root = File.expand_path("../../", __FILE__) require "#{root}/lib/aws-inventory" module Helpers def execute(cmd) puts...
github
boltops-tools/aws-inventory
https://github.com/boltops-tools/aws-inventory
spec/lib/cli_spec.rb
Ruby
mit
48
master
375
require "spec_helper" describe AwsInventory::CLI do before(:all) do @args = "" end %w[ acm cfn cw eb ec2 ecs elb help iam keypair rds route53 sg vpc ].each do |command| it command do out = execute("exe/aws-inventory #{command} #{@args}") ...