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
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit.rb
Ruby
mit
45
master
457
# frozen_string_literal: true require 'bindata' require 'active_support' require 'active_support/core_ext/class' require 'fit/file' require 'fit/file/header' require 'fit/file/record' require 'fit/file/record_header' require 'fit/file/types' require 'fit/file/type' require 'fit/file/definition' require 'fit/file/data...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file.rb
Ruby
mit
45
master
397
# frozen_string_literal: true module Fit class File def self.read(io) new.read(io) end attr_reader :header, :records, :crc def initialize @records = [] end def read(io) @header = Header.read(io) Record.clear_definitions! @records << Record.read(io) while io....
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/data.rb
Ruby
mit
45
master
3,297
# frozen_string_literal: true module Fit class File class Data < BinData::Record class_attribute :global_message_number, instance_writer: false def self.generate(definition) msg_num = definition.global_message_number.snapshot type = Definitions.get_name(msg_num) || "data_record_#{msg...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/definition.rb
Ruby
mit
45
master
3,178
# frozen_string_literal: true module Fit class File class Definition < BinData::Record class Field < BinData::Record hide :reserved_bits uint8 :field_definition_number uint8 :field_size bit1 :endian_ability bit2 :reserved_bits bit5 :base_type_number ...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/header.rb
Ruby
mit
45
master
431
# frozen_string_literal: true module Fit class File class Header < BinData::Record endian :little uint8 :header_size, check_value: -> { value >= 12 } uint8 :protocol_version uint16 :profile_version uint32 :data_size string :data_type, read_length: 4 uint16 :crc, onlyi...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/type.rb
Ruby
mit
45
master
1,024
# frozen_string_literal: true module Fit class File class Type @@types = {} def self.get_type(name) return @@types[name] if @@types.key? name type = Types.get_type_definition name @@types[name] = type ? new(type) : nil end def initialize(type) @type = ty...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/record_header.rb
Ruby
mit
45
master
763
# frozen_string_literal: true module Fit class File class RecordHeader < BinData::Record # described in section 4.1 Record Header Byte of the FIT Protocol documentation hide :reserved_bits bit1 :header_type bit1 :message_type, onlyif: :normal? bit1 :message_type_specific, initial_...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/definitions.rb
Ruby
mit
45
master
61,059
# frozen_string_literal: true module Fit class File module Definitions @@fields = Hash.new { |h, k| h[k] = {} } @@dyn_fields = Hash.new { |h, k| h[k] = {} } @@names = {} class << self def add_field(global_msg_num, field_def_num, name, options = {}) if @@fields[global_m...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/record.rb
Ruby
mit
45
master
982
# frozen_string_literal: true module Fit class File class Record @@definitions = {} mattr_reader :definitions, instance_reader: false def self.read(io) new.read(io) end def self.clear_definitions! @@definitions.clear end attr_reader :header, :content ...
github
tjwallace/fit
https://github.com/tjwallace/fit
lib/fit/file/types.rb
Ruby
mit
45
master
24,187
# frozen_string_literal: true module Fit class File module Types @@types = {} class << self def add_type(name, type, option = {}) @@types[name] = option.merge({ basic_type: type }) end def get_type_definition(name) return @@types[name] if @@types.key? nam...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
knife-xenserver.gemspec
Ruby
apache-2.0
45
master
972
# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "knife-xenserver/version" Gem::Specification.new do |s| s.name = "knife-xenserver" s.version = Knife::XenServer::VERSION s.has_rdoc = true s.authors = ["Sergio Rubio", "Pedro Perez"] s.email = ["info@bvox.n...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_template_list.rb
Ruby
apache-2.0
45
master
2,099
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 BVox S.L. # License:: Apache License, Version 2.0 # # 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:...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_vm_poweron.rb
Ruby
apache-2.0
45
master
1,445
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 Sergio Rubio # License:: Apache License, Version 2.0 # # 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 # # ht...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_vm_poweroff.rb
Ruby
apache-2.0
45
master
1,852
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 Sergio Rubio # License:: Apache License, Version 2.0 # # 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 # # ht...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_sr_create.rb
Ruby
apache-2.0
45
master
2,999
# # Author:: Sergio Rubio (<rubiojr@frameos.org>) # License:: Apache License, Version 2.0 # # 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 # ...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_host_list.rb
Ruby
apache-2.0
45
master
1,107
# # Author:: Sergio Rubio (<rubiojr@frameos.org>) # License:: Apache License, Version 2.0 # # 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 # ...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_template_create.rb
Ruby
apache-2.0
45
master
7,613
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 BVox S.L. # License:: Apache License, Version 2.0 # # 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:...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_base.rb
Ruby
apache-2.0
45
master
3,181
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: BVox S.L. (c) 2012 # License:: Apache License, Version 2.0 # # 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.apac...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_network_list.rb
Ruby
apache-2.0
45
master
1,250
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 BVox S.L. # License:: Apache License, Version 2.0 # # 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:...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_vm_list.rb
Ruby
apache-2.0
45
master
5,366
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 BVox S.L. # License:: Apache License, Version 2.0 # # 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:...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_sr_list.rb
Ruby
apache-2.0
45
master
2,514
# # Author:: Sergio Rubio (<rubiojr@frameos.org>) # License:: Apache License, Version 2.0 # # 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 # ...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_vm_delete.rb
Ruby
apache-2.0
45
master
2,307
# # Author:: Sergio Rubio (<rubiojr@frameos.org>) # Copyright:: Copyright (c) 2011 Sergio Rubio # License:: Apache License, Version 2.0 # # 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 # # ...
github
bvox/knife-xenserver
https://github.com/bvox/knife-xenserver
lib/chef/knife/xenserver_vm_create.rb
Ruby
apache-2.0
45
master
16,357
# # Author:: Sergio Rubio (<rubiojr@bvox.net>) # Copyright:: Copyright (c) 2012 BVox S.L. # License:: Apache License, Version 2.0 # # 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:...
github
azach/rules
https://github.com/azach/rules
Rakefile
Ruby
mit
45
master
700
#!/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
azach/rules
https://github.com/azach/rules
rules.gemspec
Ruby
mit
45
master
935
$:.push File.expand_path("../lib", __FILE__) # Maintain your gem's version: require "rules/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "rules" s.version = Rules::VERSION s.authors = ["Anthony Zacharakis"] s.email = ["anthony@lumoslabs....
github
azach/rules
https://github.com/azach/rules
lib/rules.rb
Ruby
mit
45
master
632
require 'rules/engine' require 'rules/extensions/active_model/absence_validator' require 'rules/extensions/active_model/parameter_key_validator' require 'rules/config' require 'rules/evaluators' require 'rules/evaluators/definitions' require 'rules/has_rules' require 'rules/parameters' require 'rules/parameters/constan...
github
azach/rules
https://github.com/azach/rules
lib/rules/evaluators.rb
Ruby
mit
45
master
370
module Rules module Evaluators require 'rules/evaluators/evaluator' @@list ||= {} def self.list @@list end def self.define_evaluator(key, &block) raise 'Evaluator already exists' if @@list[key] evaluator = Evaluator.new(key) evaluator.instance_eval(&block) if block_given...
github
azach/rules
https://github.com/azach/rules
lib/rules/parameters.rb
Ruby
mit
45
master
482
module Rules module Parameters require 'rules/parameters/parameter' require 'rules/parameters/attribute' require 'rules/parameters/constant' @@constants ||= {} def self.constants @@constants end def self.define_constant(key, &block) raise "Constant #{key} already exists" if ...
github
azach/rules
https://github.com/azach/rules
lib/rules/rule.rb
Ruby
mit
45
master
2,608
require 'rules/evaluators' require 'rules/parameters' module Rules class Rule < ActiveRecord::Base belongs_to :rule_set, class_name: 'Rules::RuleSet' validates :evaluator_key, presence: true, inclusion: {in: Evaluators.list.keys.map(&:to_s)} validates :lhs_parameter_key, parameter_key: true validate...
github
azach/rules
https://github.com/azach/rules
lib/rules/has_rules.rb
Ruby
mit
45
master
567
module Rules module HasRules def self.included(base) base.instance_eval do has_one :rule_set, class_name: 'Rules::RuleSet', as: :source, dependent: :destroy accepts_nested_attributes_for :rule_set, allow_destroy: true def has_rule_attributes(attributes = {}) Rules::RuleSe...
github
azach/rules
https://github.com/azach/rules
lib/rules/rule_set.rb
Ruby
mit
45
master
1,359
require 'rules/has_rules' require 'rules/parameters/attribute' module Rules class RuleSet < ActiveRecord::Base belongs_to :source, polymorphic: true has_many :rules, class_name: 'Rules::Rule' accepts_nested_attributes_for :rules, allow_destroy: true validates_inclusion_of :evaluation_logic, in: %w...
github
azach/rules
https://github.com/azach/rules
lib/rules/config.rb
Ruby
mit
45
master
367
require 'singleton' class Rules::Config include Singleton attr_accessor :errors_are_false, :missing_attributes_are_nil def initialize self.errors_are_false = true self.missing_attributes_are_nil = true end def missing_attributes_are_nil? !!missing_attributes_are_nil end def erro...
github
azach/rules
https://github.com/azach/rules
lib/rules/engine.rb
Ruby
mit
45
master
289
module Rules class Engine < ::Rails::Engine isolate_namespace Rules initializer :active_admin do if defined? ActiveAdmin require 'rules/extensions/active_admin/dsl' ActiveAdmin.application.javascripts << 'rules/active_admin.js' end end end end
github
azach/rules
https://github.com/azach/rules
lib/rules/extensions/active_model/absence_validator.rb
Ruby
mit
45
master
200
class AbsenceValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) record.errors.add attribute, (options[:message] || "must be blank") unless value.blank? end end
github
azach/rules
https://github.com/azach/rules
lib/rules/extensions/active_model/parameter_key_validator.rb
Ruby
mit
45
master
261
class ParameterKeyValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless record.valid_parameter_keys.include?(value) record.errors.add attribute, (options[:message] || "is not a valid parameter") end end end
github
azach/rules
https://github.com/azach/rules
lib/rules/extensions/active_admin/dsl.rb
Ruby
mit
45
master
1,782
ActiveAdmin::FormBuilder.class_eval do def has_rules inputs 'Rules' do semantic_fields_for :rule_set do |rules_rule_set_form| rules_rule_set_form.has_many :rules do |rules_rule_form| rules_rule_form.input :lhs_parameter_key, :label => 'Left hand side', collection: rules_parameter_collectio...
github
azach/rules
https://github.com/azach/rules
lib/rules/parameters/constant_definitions.rb
Ruby
mit
45
master
354
module Rules module Parameters define_constant :today do self.name = 'current date' self.type = :date self.evaluation_method = -> { Time.now.utc.to_date } end define_constant :day_of_week do self.name = 'day of week' self.evaluation_method = -> { Date::DAYNAMES[Time.now.utc....
github
azach/rules
https://github.com/azach/rules
lib/rules/parameters/attribute.rb
Ruby
mit
45
master
270
require 'rules/parameters/parameter' module Rules::Parameters class Attribute < Parameter def evaluate(attributes = {}) if Rules.config.missing_attributes_are_nil? attributes[key] else attributes.fetch(key) end end end end
github
azach/rules
https://github.com/azach/rules
lib/rules/parameters/parameter.rb
Ruby
mit
45
master
898
module Rules::Parameters class Parameter VALID_TYPES = [:date, :integer, :float, :boolean, :string, :regexp] attr_accessor :name, :type, :key def self.cast(value, type) return value unless type case type when :date Date.parse(value.to_s) when :integer value.to_i ...
github
azach/rules
https://github.com/azach/rules
lib/rules/parameters/constant.rb
Ruby
mit
45
master
276
require 'rules/parameters/parameter' module Rules::Parameters class Constant < Parameter attr_accessor :evaluation_method def evaluate(attributes = {}) raise 'Unknown evaluation method' unless evaluation_method evaluation_method.call end end end
github
azach/rules
https://github.com/azach/rules
lib/rules/evaluators/evaluator.rb
Ruby
mit
45
master
675
module Rules module Evaluators class Evaluator attr_accessor :evaluation_method, :requires_rhs, :type_for_rhs, :name def initialize(key) @name = key.to_s @requires_rhs = true end def evaluate(lhs, rhs = nil) raise 'Unknown evaluation method' unless evaluation_meth...
github
azach/rules
https://github.com/azach/rules
lib/rules/evaluators/definitions.rb
Ruby
mit
45
master
2,094
module Rules module Evaluators define_evaluator :equals do self.evaluation_method = ->(lhs, rhs) { lhs == rhs } self.requires_rhs = true end define_evaluator :not_equals do self.evaluation_method = ->(lhs, rhs) { lhs != rhs } self.name = 'does not equal' self.requires_rhs = ...
github
azach/rules
https://github.com/azach/rules
db/migrate/20120831173835_create_rule_sets.rb
Ruby
mit
45
master
218
class CreateRuleSets < ActiveRecord::Migration def change create_table :rules_rule_sets do |t| t.belongs_to :source, polymorphic: true t.string :evaluation_logic t.timestamps end end end
github
azach/rules
https://github.com/azach/rules
spec/spec_helper.rb
Ruby
mit
45
master
1,486
# This file is copied to spec/ when you run 'rails generate rspec:install' ENV["RAILS_ENV"] ||= 'test' require File.expand_path("../dummy/config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'rspec/collection_matchers' # Requires supporting ruby files with custom matchers and macros, et...
github
azach/rules
https://github.com/azach/rules
spec/dummy/app/admin/orders.rb
Ruby
mit
45
master
455
ActiveAdmin.register Order do show do |f| attributes_table do row :id row :quantity row :price row :customer row :placed row :shipped row :created_at row :updated_at end show_rules end form do |f| f.inputs 'Details' do f.input :quantity ...
github
azach/rules
https://github.com/azach/rules
spec/dummy/app/admin/dashboards.rb
Ruby
mit
45
master
947
ActiveAdmin.register_page "Dashboard" do menu :priority => 1, :label => proc{ I18n.t("active_admin.dashboard") } content :title => proc{ I18n.t("active_admin.dashboard") } do div :class => "blank_slate_container", :id => "dashboard_default_message" do span :class => "blank_slate" do span "Welcom...
github
azach/rules
https://github.com/azach/rules
spec/dummy/app/models/admin_user.rb
Ruby
mit
45
master
286
class AdminUser < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :confirmable, # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable end
github
azach/rules
https://github.com/azach/rules
spec/dummy/app/models/order.rb
Ruby
mit
45
master
298
class Order < ActiveRecord::Base include Rules::HasRules has_rule_attributes({ customer_email: { name: 'customer email address' }, order_price: { name: 'order price' } }) def check_if_valid evaluate \ customer: customer, price: price end end
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/schema.rb
Ruby
mit
45
master
2,871
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative sou...
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/migrate/20120901044906_create_admin_notes.rb
Ruby
mit
45
master
472
class CreateAdminNotes < ActiveRecord::Migration def self.up create_table :admin_notes do |t| t.string :resource_id, :null => false t.string :resource_type, :null => false t.references :admin_user, :polymorphic => true t.text :body t.timestamps end add_index :admin_notes, [:r...
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/migrate/20121029183622_create_rules.rules.rb
Ruby
mit
45
master
248
# This migration comes from rules (originally 20120831163952) class CreateRules < ActiveRecord::Migration def change create_table :rules_rules do |t| t.belongs_to :rule_set t.text :expression t.timestamps end end end
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/migrate/20120821181654_create_orders.rb
Ruby
mit
45
master
245
class CreateOrders < ActiveRecord::Migration def change create_table :orders do |t| t.integer :quantity t.decimal :price t.string :customer t.date :placed t.date :shipped t.timestamps end end end
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/migrate/20120901044842_devise_create_admin_users.rb
Ruby
mit
45
master
1,729
class DeviseCreateAdminUsers < ActiveRecord::Migration def migrate(direction) super # Create a default user AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') if direction == :up end def change create_table(:admin_users) do |t| ##...
github
azach/rules
https://github.com/azach/rules
spec/dummy/db/migrate/20121029183623_create_rule_sets.rules.rb
Ruby
mit
45
master
280
# This migration comes from rules (originally 20120831173835) class CreateRuleSets < ActiveRecord::Migration def change create_table :rules_rule_sets do |t| t.belongs_to :source, polymorphic: true t.string :evaluation_logic t.timestamps end end end
github
azach/rules
https://github.com/azach/rules
spec/dummy/config/application.rb
Ruby
mit
45
master
1,114
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Dummy class Application < Rails::Application # Settings in config/environments/* take precede...
github
azach/rules
https://github.com/azach/rules
spec/dummy/config/environments/development.rb
Ruby
mit
45
master
1,600
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 serv...
github
azach/rules
https://github.com/azach/rules
spec/dummy/config/environments/production.rb
Ruby
mit
45
master
3,304
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 # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web serve...
github
azach/rules
https://github.com/azach/rules
spec/dummy/config/initializers/devise.rb
Ruby
mit
45
master
11,341
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use yo...
github
azach/rules
https://github.com/azach/rules
spec/dummy/config/initializers/secret_token.rb
Ruby
mit
45
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
azach/rules
https://github.com/azach/rules
spec/dummy/config/initializers/active_admin.rb
Ruby
mit
45
master
4,136
ActiveAdmin.setup do |config| # == Site Title # # Set the title that is displayed on the main layout # for each of the active admin pages. # config.site_title = "Dummy" # Set the link url for the title. For example, to take # users to your main site. Defaults to no link. # # config.site_title_link...
github
azach/rules
https://github.com/azach/rules
spec/rules/rule_spec.rb
Ruby
mit
45
master
10,902
require 'spec_helper' describe Rules::Rule do let(:rule_set) { Rules::RuleSet.new } let(:evaluator_key) { 'equals' } let(:lhs) { 'today' } let(:rhs_key) { 'today' } let(:rhs_raw) { Date.today.to_s } describe 'validations' do it 'requires a valid evaluator' do rule = Rules::Rule.new(evaluator_key...
github
azach/rules
https://github.com/azach/rules
spec/rules/rule_set_spec.rb
Ruby
mit
45
master
3,432
require 'spec_helper' describe Rules::RuleSet do let(:rule_set) { Rules::RuleSet.new } let(:attributes) { {attribute1: {name: 'name of attribute 1'}, attribute2: {name: 'name of attribute 2'}} } before { stub_const('FakeClass', Class.new) } describe '.set_attributes_for' do it 'returns an empty hash if t...
github
azach/rules
https://github.com/azach/rules
spec/rules/evaluators_spec.rb
Ruby
mit
45
master
1,007
require 'spec_helper' describe Rules::Evaluators do describe '.define_evaluator' do it 'fails if the key already exists' do Rules::Evaluators.define_evaluator :duplicate expect { Rules::Evaluators.define_evaluator :duplicate }.to raise_error('Evaluator already exists') end it '...
github
azach/rules
https://github.com/azach/rules
spec/rules/parameters/attribute_spec.rb
Ruby
mit
45
master
876
require 'spec_helper' describe Rules::Parameters::Attribute do let (:user) do stub('user', name: 'terry').tap do |u| u.stub_chain(:account, :balance).and_return(100) end end let(:attribute) { Rules::Parameters::Attribute.new(key: 'test_key') } describe '#evaluate' do it 'retrieves the attr...
github
azach/rules
https://github.com/azach/rules
spec/rules/evaluators/definitions_spec.rb
Ruby
mit
45
master
1,658
require 'spec_helper' describe Rules::Evaluators do describe 'equals' do it 'returns true if two objects are the same' do Rules::Evaluators.list[:equals].evaluate(1.0, 1.0).should be_truthy Rules::Evaluators.list[:equals].evaluate('romeo', 'romeo').should be_truthy Rules::Evaluators.list[:equal...
github
azach/rules
https://github.com/azach/rules
spec/rules/evaluators/evaluator_spec.rb
Ruby
mit
45
master
1,103
require 'spec_helper' describe Rules::Evaluators::Evaluator do describe '#evaluate' do let(:evaluator) { Rules::Evaluators::Evaluator.new(:test) } let(:lhv) { 'lhv' } let(:rhv) { 'rhv' } it 'raises an error if a block is not defined' do expect { evaluator.evaluate(lhv, rhv) }.to ...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
Gemfile
Ruby
mit
45
master
209
# frozen_string_literal: true source 'https://rubygems.org' gem 'ast' gem 'aws-sdk' gem 'cfn-nag' gem 'cucumber' gem 'eat' gem 'english' gem 'json' gem 'rspec' gem 'rubocop' gem 'serverspec' gem 'simplecov'
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/cfn_nag/lib/cfn-nag/custom_rules/InternetGatewayRule.rb
Ruby
mit
45
master
448
# frozen_string_literal: true require 'cfn-nag/violation' require 'cfn-nag/custom_rules/base' class InternetGatewayRule < BaseRule def rule_text 'Internet Gateways are not allowed' end def rule_type Violation::WARNING end def rule_id 'W99' end def audit_impl(cfn_model) violating_resou...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/capacity.rb
Ruby
mit
45
master
841
# frozen_string_literal: true require 'aws-sdk' require 'json' require 'pipeline/cfn_helper' require 'pipeline/state' # Pipeline module Pipeline # Class for handling inspector tests class Capacity < CloudFormationHelper def initialize @cloudformation = Aws::CloudFormation::Client ...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/cfn_helper.rb
Ruby
mit
45
master
2,145
# frozen_string_literal: true require 'aws-sdk' require 'pipeline/cfn_helper' # Pipeline module Pipeline # Provides helper methods for provisioning class CloudFormationHelper def aws_region return 'us-east-1' if ENV['AWS_REGION'].nil? ENV['AWS_REGION'] end def cfn_parameters(template_nam...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/deploy.rb
Ruby
mit
45
master
2,704
# frozen_string_literal: true require 'aws-sdk' require 'eat' require 'pipeline/state' require 'pipeline/cfn_helper' # Pipeline module Pipeline # Deployment class for all environments class Deploy < CloudFormationHelper def initialize(params = {}) @params = params @cloudformation = Aws::CloudForma...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/state.rb
Ruby
mit
45
master
796
# frozen_string_literal: true require 'aws-sdk' require 'json' module Pipeline # Class for handling pipeline state class State def self.store(namespace: 'global', key: '', value: '') storage = grab_pipeline_store storage[namespace] ||= {} storage[namespace][key] = value write_pipeline_...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/penetration.rb
Ruby
mit
45
master
1,259
# frozen_string_literal: true require 'aws-sdk' require 'json' require 'pipeline/cfn_helper' require 'pipeline/state' # Pipeline module Pipeline # Class for handling inspector tests class Penetration < CloudFormationHelper def initialize @cloudformation = Aws::CloudFormation::Client.new(region: aws_regi...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/inspector.rb
Ruby
mit
45
master
1,443
# frozen_string_literal: true require 'fileutils' module Pipeline # Class for handling inspector tests class Inspector def initialize(params = {}) @params = params @params[:region] = ENV['AWS_REGION'] @params[:region] ||= 'us-east-1' run_inspector end def run_inspector p...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/lib/pipeline/configservice.rb
Ruby
mit
45
master
1,246
# frozen_string_literal: true require 'aws-sdk' module Pipeline # Class for handling ConfigService tests class ConfigService def initialize(params = {}) @params = params @params[:region] = ENV['AWS_REGION'] @params[:region] ||= 'us-east-1' @configservice = Aws::ConfigService::Client.ne...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/smoke-test.rake
Ruby
mit
45
master
259
# frozen_string_literal: true require 'cucumber/rake/task' namespace :deployment do desc 'Smoke test the production deployment' Cucumber::Rake::Task.new(:smoke_test) do |t| t.cucumber_opts = '--tags @production features/webserver.feature' end end
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/integration-test.rake
Ruby
mit
45
master
618
# frozen_string_literal: true require 'rspec/core/rake_task' require 'cucumber/rake/task' namespace :acceptance do desc 'Integration test the acceptance environment' task integration_test: %i[acceptance:serverspec acceptance:cucumber] desc 'Integration tests for server configuration' RSpec::Core::RakeTask.ne...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/create-environment.rake
Ruby
mit
45
master
279
# frozen_string_literal: true require 'pipeline/deploy' require 'pipeline/state' namespace :acceptance do desc 'Create acceptance environment' task :create_environment do puts 'Create acceptance environment' Pipeline::Deploy.new environment: 'acceptance' end end
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/build.rake
Ruby
mit
45
master
563
# frozen_string_literal: true namespace :commit do desc 'Build application' task :build do # no op puts 'The application is build from cloudformation userdata.' end # desc 'Install custom CFN_Nag rules' # task :'cfn_nag:rules' do # puts 'Install custom CFN_Nag rules' # # cfn_nag_path = File....
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/unit-test.rake
Ruby
mit
45
master
391
# frozen_string_literal: true namespace :commit do desc 'CFN_NAG unit tests for custom rules' task cfn_nag_unit_tests: [:unit_test_cfn_nag_custom_rules] end begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:unit_test_cfn_nag_custom_rules) do |t| t.pattern = 'test/unit/spec/**/*_spec.rb' e...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/static-analysis.rake
Ruby
mit
45
master
281
# frozen_string_literal: true namespace :commit do desc 'Static analysis tests' task static_analysis: [:rubocop] end begin require 'rubocop/rake_task' RuboCop::RakeTask.new(:rubocop) rescue LoadError puts "Unable to load rubocop/rake_task, rubocop tests missing\n" end
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/security-test.rake
Ruby
mit
45
master
1,124
# frozen_string_literal: true require 'cfn-nag' require 'pipeline/inspector' require 'pipeline/penetration' require 'pipeline/configservice' namespace :commit do desc 'Static security tests' task :security_test do puts "\n\nCFN-NAG Static security tests" cfn_templates_path = "#{Dir.pwd}/provisioning/cloud...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/capacity-test.rake
Ruby
mit
45
master
239
# frozen_string_literal: true require 'pipeline/capacity' namespace :capacity do desc 'Capacity test acceptance environment' task :capacity_test do puts 'Capacity test acceptance environment' Pipeline::Capacity.new end end
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
pipeline/tasks/production-deploy.rake
Ruby
mit
45
master
227
# frozen_string_literal: true namespace :deployment do desc 'Deploy the production environment' task :production do puts 'Deploy the production environment' Pipeline::Deploy.new environment: 'production' end end
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
features/step_definitions/webserver.rb
Ruby
mit
45
master
1,035
#!/usr/bin/env ruby $LOAD_PATH << './pipeline/lib' require 'cucumber' require 'eat' require 'pipeline/state' require 'rspec' require 'socket' require 'timeout' Given(/^that the "([^"]*)" server has a public IP address$/) do |environment| @target_host = Pipeline::State.retrieve(environment, 'WEBSERVER_IP') expect...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
features/step_definitions/capacity_test.rb
Ruby
mit
45
master
369
#!/usr/bin/env ruby require 'rspec' Given(/^we have a result set from Apache Benchmark$/) do expect(File.exist?('capacity_result.txt')).to be true end Then(/^there should be no failed requests$/) do results = /Failed\srequests\:\s+(\d+)/ .match(File.read('capacity_result.txt')) expect(results[1]).not_to b...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
test/integration/serverspec/spec/spec_helper.rb
Ruby
mit
45
master
451
# frozen_string_literal: true $LOAD_PATH << './pipeline/lib' require 'serverspec' require 'net/ssh' require 'pipeline/state' target_host = Pipeline::State.retrieve('acceptance', 'WEBSERVER_PRIVATE_IP') keypair_path = Pipeline::State.retrieve('acceptance', 'KEYPAIR_PATH') set :backend, :ssh set :host, target_host s...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
test/integration/serverspec/spec/server/server_spec.rb
Ruby
mit
45
master
451
# frozen_string_literal: true require 'serverspec' require_relative '../spec_helper' describe 'Server Setup' do # Verify packages installed %w[perl-devel zlib-devel openssl-devel gcc make].each do |package_name| describe package(package_name) do it { should be_installed } end end # Verify the A...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
test/integration/serverspec/spec/nginx/nginx_spec.rb
Ruby
mit
45
master
816
# frozen_string_literal: true require 'serverspec' require_relative '../spec_helper' describe 'Nginx Installation' do # Nginx downloaded in correct location describe file('/usr/share/nginx') do it { should exist } it { should be_directory } end # Correct version of nginx # describe command('/usr/sb...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
test/unit/spec/spec_helper.rb
Ruby
mit
45
master
5,238
# frozen_string_literal: true $LOAD_PATH << './pipeline/lib' require 'simplecov' require 'open3' SimpleCov.start do add_filter 'spec/' end # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. # The generated `.rsp...
github
stelligent/aws-devsecops-workshop
https://github.com/stelligent/aws-devsecops-workshop
test/unit/spec/cfn_nag_custom_rules/InternetGatewayRule_spec.rb
Ruby
mit
45
master
1,176
# frozen_string_literal: true require_relative '../spec_helper' require 'cfn-model' require 'cfn_nag/lib/cfn-nag/custom_rules/InternetGatewayRule' describe InternetGatewayRule do context 'When an AWS::EC2::InternetGateway resource exists in a CloudFormation template' do it 'returns logical resource ID for the o...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
Rakefile
Ruby
mit
44
master
525
begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'Omniauth::Okta' rdoc.options << '--line-numbers' rdoc.rdoc_files.include('README.md') ...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
omniauth-okta.gemspec
Ruby
mit
44
master
827
$:.push File.expand_path("../lib", __FILE__) require "omniauth-okta/version" Gem::Specification.new do |s| s.name = "omniauth-okta" s.version = OmniAuth::Okta::VERSION s.authors = ['Dan Andrews', 'Hector Rios'] s.email = ['daniel.raymond.andrews@gmail.com', 'that.hector@gmail.com'...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
Gemfile
Ruby
mit
44
master
568
source 'https://rubygems.org' # Declare your gem's dependencies in omniauth-okta.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 instead o...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
lib/omniauth/strategies/okta.rb
Ruby
mit
44
master
3,390
# frozen_string_literal: true require 'omniauth-oauth2' module OmniAuth module Strategies class Okta < OmniAuth::Strategies::OAuth2 DEFAULT_SCOPE = %{openid profile email}.freeze option :name, 'okta' option :skip_jwt, false option :jwt_leeway, 60 # These are defaults that need to...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
spec/spec_helper.rb
Ruby
mit
44
master
725
# frozen_string_literal: true require 'rspec' require 'rack/test' require 'omniauth' require 'omniauth-okta' # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.include Rack::Test::Methods ...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
spec/omniauth/strategies/okta_spec.rb
Ruby
mit
44
master
5,245
# frozen_string_literal: true require 'spec_helper' describe OmniAuth::Strategies::Okta do include OmniAuth::Test::StrategyTestCase subject { described_class.new({}) } let(:base_url) { 'https://your-org.okta.com' } let(:strategy) { described_class } let(:access_token_string) do "eyJhbGciOiJSUzI1NiJ9.ey...
github
omniauth/omniauth-okta
https://github.com/omniauth/omniauth-okta
example/config.ru
Ruby
mit
44
master
787
# frozen_string_literal: true # Sample app for Okta OAuth2 Strategy # Make sure to setup the ENV variables OKTA_CLIENT_ID and OKTA_CLIENT_SECRET # Run with "bundle exec rackup" require 'bundler/setup' require 'sinatra/base' require 'omniauth-okta' class OktaExample < Sinatra::Base use Rack::Session::Cookie, :secre...
github
displayful/turnstiled
https://github.com/displayful/turnstiled
turnstiled.gemspec
Ruby
mit
45
main
1,193
require_relative "lib/turnstiled/version" Gem::Specification.new do |spec| spec.name = "turnstiled" spec.version = Turnstiled::VERSION spec.authors = [ "Displayful", "Henrik Hauge Bjørnskov" ] spec.email = [ "hb@displayful.co" ] spec.license = "MIT" spec.homepage = "https://gith...
github
displayful/turnstiled
https://github.com/displayful/turnstiled
lib/turnstiled.rb
Ruby
mit
45
main
444
module Turnstiled autoload :ControllerMethods, "turnstiled/controller_methods" autoload :ViewHelper, "turnstiled/view_helper" autoload :Verifier, "turnstiled/verifier" autoload :VERSION, "turnstiled/version" mattr_accessor :site_key mattr_accessor :site_secret mattr_accessor :mock, default: Rails.env.loc...