repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
psparrow/attr-gather | spec/attr/gather/aggregators_spec.rb | # frozen_string_literal: true
module Attr
module Gather
RSpec.describe Aggregators do
describe '.default' do
it 'is the :deep_merge aggregator' do
expect(described_class.default).to be_a(Aggregators::DeepMerge)
end
end
describe '.resolve' do
it 'resolves a nam... |
psparrow/attr-gather | lib/attr/gather/filters/result.rb | # frozen_string_literal: true
module Attr
module Gather
module Filters
# Result of a filter
#
# @!attribute [r] value
# @return [Hash] the filtered hash
#
# @!attribute [r] filterings
# @return [Array<Attr::Gather::Filtering>] info about filtered items
class Re... |
psparrow/attr-gather | lib/attr/gather/aggregators.rb | # frozen_string_literal: true
require 'attr/gather/concerns/registrable'
module Attr
module Gather
# Namespace for aggregators
module Aggregators
extend Registrable
# The default aggregator if none is specified
#
# @return [Attr::Gather::Aggregators::DeepMerge]
def self.defaul... |
psparrow/attr-gather | lib/attr-gather.rb | <gh_stars>10-100
# frozen_string_literal: true
require 'attr/gather'
|
psparrow/attr-gather | lib/attr/gather/filters/filtering.rb | # frozen_string_literal: true
module Attr
module Gather
module Filters
# Information about a filtered item
#
# @!attribute [r] path
# @return [Hash] path of the filtered key
#
# @!attribute [r] reason
# @return [String] why the item was filtered
#
# @!att... |
psparrow/attr-gather | spec/shared/user_workflow.rb | <filename>spec/shared/user_workflow.rb
# frozen_string_literal: true
RSpec.shared_context 'user workflow' do
let(:user_workflow_class) do
workflow_class = Class.new do
include Attr::Gather::Workflow
task :good do |t|
t.depends_on = []
end
task :bad do |t|
t.depends_on = ... |
psparrow/attr-gather | lib/attr/gather/workflow/task_executor.rb | <filename>lib/attr/gather/workflow/task_executor.rb
# frozen_string_literal: true
require 'concurrent'
require 'attr/gather/workflow/task_execution_result'
module Attr
module Gather
module Workflow
# @api private
class TaskExecutor
attr_reader :batch, :container, :executor
def initi... |
alebian/passman | spec/manager_spec.rb | <reponame>alebian/passman
require 'spec_helper'
require 'json'
describe Passman::Manager do
subject(:manager) { described_class.new(file_path) }
let(:file_path) { './spec/passman.json' }
let(:account) { 'test_account' }
let(:username) { 'test_username' }
let(:password) { '<PASSWORD>' }
let(:key... |
alebian/passman | spec/crypto_spec.rb | require 'spec_helper'
describe Passman::Crypto do
describe 'encrypting data' do
let!(:password) { '<PASSWORD>' }
let!(:key) { 'supermegaarchisecurekeyofmorethan32bitslong' }
it 'encrypts the password correctly' do
expect(described_class.encrypt(password, key)).not_to eq password
end
it 'd... |
alebian/passman | lib/passman/crypto.rb | <gh_stars>1-10
require 'openssl'
require 'bcrypt'
require 'base64'
module Passman
class Crypto
AVAILABLE_CIPHERS = %w[aes-256-cbc aes-128-gcm aes-256-gcm].freeze
MINIMUM_SIZE_KEY = 32
DOWNCASE_DICTIONARY = ('a'..'z').to_a.freeze
UPCASE_DICTIONARY = ('A'..'Z').to_a.freeze
NUMBERS_DICTIONARY... |
alebian/passman | lib/passman.rb | require 'passman/crypto'
require 'passman/manager'
require 'passman/version'
module Passman
end
|
alebian/passman | spec/spec_helper.rb | <filename>spec/spec_helper.rb<gh_stars>1-10
require 'simplecov'
SimpleCov.start
require 'passman'
require 'byebug'
|
alebian/passman | lib/passman/manager.rb | <gh_stars>1-10
require 'passman/crypto'
require 'json'
module Passman
class Manager
DEFAULT_PATH = 'passman.json'.freeze
def initialize(file = nil)
@file_path = DEFAULT_PATH
@file_path = file unless file.nil?
end
def generate_password(length = 32)
<PASSWORD>man::Crypto.generate_pa... |
alebian/passman | passman.gemspec | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'passman/version'
require 'date'
Gem::Specification.new do |spec|
spec.name = 'passman'
spec.version = Passman::VERSION
spec.authors = ['<NAME>']
spec.email = ... |
alebian/passman | spec/project_spec.rb | <reponame>alebian/passman
require 'spec_helper'
describe 'PassMan Project' do
context 'when checking the gem version' do
let(:version) { Passman::VERSION }
it 'is the correct version' do
expect(version).to eq('0.2.0')
end
end
end
|
ngergo100/carthframie | spec/carthframie_spec.rb | RSpec.describe Carthframie do
it "has a version number" do
expect(Carthframie::VERSION).not_to be nil
end
it "has frameworks path" do
expect(Carthframie::CarthageCopyFrameworks::CARTHAGE_FRAMEWORKS_PATH).to eq("Carthage/Build/**/*.framework")
end
it "has build phase name" do
expect(Carthfram... |
ngergo100/carthframie | lib/carthframie.rb | require "carthframie/version"
require "xcodeproj"
require "thor"
module Carthframie
class CarthageCopyFrameworks
CARTHAGE_FRAMEWORKS_PATH = "Carthage/Build/**/*.framework"
COPY_CARTHAGE_BUILD_PHASE_NAME = "Copy Carthage frameworks"
COPY_CARTHAGE_BUILD_PHASE_SHELL_SCRIPT = "/usr/local/bin/carthage copy-... |
pcg79/nfl_api | spec/nfl_api/models/roster_spec.rb | <reponame>pcg79/nfl_api<filename>spec/nfl_api/models/roster_spec.rb
require 'spec_helper'
describe NFLApi::Roster do
let(:teams_current_season_endpoint) { File.join(File.dirname(__FILE__), "..", "..", "fixtures", "nfl_teams.json") }
let(:roster_current_season_endpoint) { File.join(File.dirname(__FILE__), "..", ".... |
pcg79/nfl_api | lib/nfl_api/models.rb | require "nfl_api/models/base"
require "nfl_api/models/team"
require "nfl_api/models/conference"
require "nfl_api/models/division"
require "nfl_api/models/roster"
require "nfl_api/models/player"
|
pcg79/nfl_api | lib/nfl_api/models/player.rb | module NFLApi
class Player < Base
# "season": 2019,
# "nflId": 2562817,
# "status": "ACT",
# "displayName": "<NAME>",
# "firstName": "B.J.",
# "lastName": "Blunt",
# "esbId": "BLU745149",
# "gsisId": "00-0034923",
# ... |
pcg79/nfl_api | spec/nfl_api/models/team_spec.rb | require 'spec_helper'
describe NFLApi::Team do
let(:current_season_endpoint) { File.join(File.dirname(__FILE__), "..", "..", "fixtures", "nfl_teams.json") }
let(:season_specific_endpoint) { File.join(File.dirname(__FILE__), "..", "..", "fixtures", "nfl_teams_2018.json") }
context ".all" do
it "returns the c... |
pcg79/nfl_api | lib/nfl_api.rb | require "nfl_api/version"
require "nfl_api/models"
module NFLApi
NFL_START_YEAR = 1920
end
|
pcg79/nfl_api | lib/nfl_api/models/division.rb | <reponame>pcg79/nfl_api<gh_stars>0
module NFLApi
class Division
# "division":{"id":"0018",
# "abbr":"NCW",
# "fullName":"NFC West Division"},
attr_reader :id, :abbr, :full_name
def initialize(params)
@id = params["id"]
@abbr = params["abbr"]
@full_name = params["fullName"]
... |
pcg79/nfl_api | lib/nfl_api/models/team.rb | <filename>lib/nfl_api/models/team.rb
module NFLApi
class Team < Base
# {"season":2019,
# "teamId":"3800",
# "abbr":"ARI",
# "cityState":"Arizona",
# "fullName":"<NAME>",
# "nick":"Cardinals",
# "teamType":"TEAM",
# "conferenceAbbr":"NFC",
# "divisionAbbr":"NCW",
# "conference":... |
pcg79/nfl_api | lib/nfl_api/models/base.rb | <reponame>pcg79/nfl_api
require 'open-uri'
require 'json'
module NFLApi
class Base
def self.parse_json(endpoint)
JSON.load(open(endpoint))
end
end
end
|
pcg79/nfl_api | spec/spec_helper.rb | <reponame>pcg79/nfl_api
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
require 'webmock/rspec'
require 'pry-byebug'
require 'nfl_api'
|
pcg79/nfl_api | lib/nfl_api/models/conference.rb | module NFLApi
class Conference
# "conference":{"id":"0015",
# "abbr":"NFC",
# "fullName":"National Football Conference"},
attr_reader :id, :abbr, :full_name
def initialize(params)
@id = params["id"]
@abbr = params["abbr"]
@full_name = params["fullName"]
end
end
end
|
pcg79/nfl_api | lib/nfl_api/models/roster.rb | module NFLApi
class Roster < Base
# {
# "season": 2019,
# "team": {
# "season": 2019,
# "teamId": "5110",
# "abbr": "WAS",
# "cityState": "Washington",
# "fullName": "<NAME>",
# "nick": "Redskins",
# "teamType": "T... |
pcg79/nfl_api | spec/nfl_api_test.rb | require "spec_helper"
describe NFLApiTest
def test_that_it_has_a_version_number
refute_nil ::NFLApi::VERSION
end
end
|
jskyzero/design.jskyzero.com | _plugins/time_checker.rb | <filename>_plugins/time_checker.rb
# # does not work
# # unhappy
# module Jekyll
# module TimeFilter
# private
# def compare(posted_time, modified_time)
# # checker = DateTime.new(2021, 10, 1, 0, 0, 0, now.zone).to_s
# # posted_time > checker
# false
# end
# def sort_post_filter(... |
jskyzero/design.jskyzero.com | _plugins/post-data-last-modified-at.rb | # frozen_string_literal: true
require 'fileutils'
require 'pathname'
require 'jekyll-last-modified-at'
module Recents
# Generate change information for all markdown pages
class Generator < Jekyll::Generator
def generate(site)
items = site.posts.docs.select { |p| p.path.end_with? '.md' }
items.each... |
work-furukawa/ruboty-whatday | lib/ruboty/whatday/actions/whatday.rb | require 'wikipedia'
require 'date'
module Ruboty
module Whatday
module Actions
class Whatday < Ruboty::Actions::Base
WIKIPEDIA_DOMAIN_JP = 'ja.wikipedia.org'
WIKI_API_PARAMS = {
format: 'json',
action: 'query',
prop: 'revisions',
rvprop: 'content',
... |
work-furukawa/ruboty-whatday | lib/ruboty/whatday/version.rb | module Ruboty
module Whatday
VERSION = "0.1.0"
end
end
|
work-furukawa/ruboty-whatday | lib/ruboty/whatday.rb | <gh_stars>0
require "ruboty/whatday/version"
require 'ruboty/handlers/whatday'
module Ruboty
module Whatday
class Error < StandardError; end
# Your code goes here...
end
end
|
work-furukawa/ruboty-whatday | lib/ruboty/handlers/whatday.rb | require "ruboty/whatday/actions/whatday"
module Ruboty
module Handlers
class Whatday < Base
on(
/(date) (?<mmdd>.+) (?<keyword>.+)*/,
name: 'whatday',
description: 'output what day'
)
def whatday(message)
Ruboty::Whatday::Actions::Whatday.new(message).call
... |
eggc/gc_dm | lib/gc_dm.rb | <reponame>eggc/gc_dm<filename>lib/gc_dm.rb
require "gc_dm/version"
require "gc_dm/room"
require "gc_dm/rooms"
require "gc_dm/room_html_parser"
require "gc_dm/rooms_html_parser"
require "gc_dm/cache_manager"
module GcDm
class Error < StandardError; end
# Your code goes here...
end
|
eggc/gc_dm | lib/gc_dm/rooms.rb | <gh_stars>0
module GcDm
class Rooms
def initialize(rooms = [])
@rooms = rooms
end
def load
parser = RoomsHtmlParser.new
@rooms = parser.get_rooms
@rooms.each do |room|
parser = RoomHtmlParser.new(room.href)
room.rank = parser.get_rank
recipe = parser.get_re... |
eggc/gc_dm | lib/gc_dm/cache_manager.rb | module GcDm
class CacheManager
CACHE_PATH = "/tmp/gcdm-cache"
def self.load
cache = File.read(CACHE_PATH)
Marshal.load(cache)
end
def self.save(object)
File.open(CACHE_PATH, "wb") do |f|
f.write(Marshal.dump(object))
end
end
end
end
|
eggc/gc_dm | lib/gc_dm/rooms_html_parser.rb | <gh_stars>0
require "open-uri"
require "open-uri/cached"
require "nokogiri"
module GcDm
class RoomsHtmlParser
URL = "https://wikiwiki.jp/duma/%E3%83%80%E3%83%B3%E3%82%B8%E3%83%A7%E3%83%B3%E3%81%AE%E9%83%A8%E5%B1%8B"
def initialize
html = open(URL).read
@doc = Nokogiri::HTML.parse(html)
rem... |
eggc/gc_dm | lib/gc_dm/room.rb | module GcDm
class Room < Struct.new(:name, :description, :href, :materials, :rank)
# この部屋を作成するのに必要なアトムの総数を返す
# @return [Hash] キーがアトムの名前、値が部屋の数
def atoms
if materials && !materials.empty?
materials.each_with_object({}) do |material, result|
material.atoms.each do |k, v|
... |
eggc/gc_dm | lib/gc_dm/room_html_parser.rb | <reponame>eggc/gc_dm
require "open-uri"
require "open-uri/cached"
require "nokogiri"
module GcDm
class RoomHtmlParser
HOST = "https://wikiwiki.jp/"
def initialize(path)
url = HOST + path
html = open(url).read
@doc = Nokogiri::HTML.parse(html)
end
def get_recipe
@doc.css("tab... |
eggc/gc_dm | lib/gc_dm/version.rb | module GcDm
VERSION = "0.1.0"
end
|
iCentris/ias_active_directory | spec/ias_active_directory/field_type/date_spec.rb | <filename>spec/ias_active_directory/field_type/date_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::IasActiveDirectory::FieldType::Date do
describe 'concerning .encode' do
it 'can encode' do
time = Time.now
expect(described_class.encode(time)).to eq(time.strftime('%Y%m%d... |
iCentris/ias_active_directory | lib/ias_active_directory/field_type/date.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# FieldType Namespace
module FieldType
# Date Field Type
class Date
# Converts a time object into an ISO8601 format compatable with Active Directory
def self.encode(local_time)
local_time.strftime('%Y... |
iCentris/ias_active_directory | lib/ias_active_directory/member.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# Member module for Users/Groups
module Member
# Returns true if this member (User or Group) is a member of
# the passed Group object.
def member?(usergroup)
group_dns = memberOf
return false if group_dns... |
iCentris/ias_active_directory | lib/ias_active_directory/attributes/group_type.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# Group Type Constants
module GroupType
# Local Group Mask
BUILTIN_LOCAL_GROUP = 0x00000001
# Account Group Mask
ACCOUNT_GROUP = 0x00000002
# Resource Group Mask
RESSOURCE_GROUP = 0x00000004
... |
iCentris/ias_active_directory | lib/ias_active_directory/sid.rb | <gh_stars>0
# frozen_string_literal: true
# IasActiveDirectory Namespace
module IasActiveDirectory
# @!attribute revision
# Revision Number
# @!attribute dashes
# Dashes number
# @!attribute nt_authority
# NT Authority
# @!attribute nt_non_unique
# NT Non Unique
# @!attribute uuids
# Array of ... |
iCentris/ias_active_directory | lib/ias_active_directory/version.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# Our current Version
VERSION = '0.1.0'
end
|
iCentris/ias_active_directory | spec/ias_active_directory/base_spec.rb | # frozen_string_literal: true
RSpec.describe IasActiveDirectory::Base do
describe 'concerning constant' do
context 'NIL_FILTER' do
it 'knows the NIL_FILTER class' do
expect(described_class::NIL_FILTER).to be_a(Net::LDAP::Filter)
end
it 'knows the @left attribute' do
expect(desc... |
iCentris/ias_active_directory | lib/ias_active_directory/attributes/sam_account_type.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# SAM Account Type constants
module SamAccountType
# Domain Object Mask
DOMAIN_OBJECT = 0x0
# Group Object Mask
GROUP_OBJECT = 0x10000000
# Non Security Group Object Mask
NON_SE... |
iCentris/ias_active_directory | lib/ias_active_directory/container.rb | <filename>lib/ias_active_directory/container.rb
# frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
#
# The ::IasActiveDirectory::Container class represents a more malleable way
# of dealing with LDAP Distinguished Names (dn), like
# "cn=UserName,ou=Users,dc=example,dc=org".
... |
iCentris/ias_active_directory | lib/ias_active_directory/group.rb | # frozen_string_literal: true
require 'ias_active_directory/attributes'
# IasActiveDirectory namespace
module IasActiveDirectory
# ActiveDirectory Group Object
class Group < Base
include Member
def self.filter # :nodoc:
Net::LDAP::Filter.eq(:objectClass, 'group')
end
def self.required_attr... |
iCentris/ias_active_directory | spec/ias_active_directory/attributes/group_type_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::IasActiveDirectory::GroupType do
describe 'concerning constants' do
it 'knows BUILTIN_LOCAL_GROUP' do
expect(described_class::BUILTIN_LOCAL_GROUP).to eql(0x00000001)
end
it 'knows ACCOUNT_GROUP' do
expect(described_class::... |
iCentris/ias_active_directory | lib/ias_active_directory/user.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# Users in ActiveDirectory
class User < Base
include Member
UAC_ACCOUNT_DISABLED = 0x0002 # User Account Control Account Disabled Mask
UAC_NORMAL_ACCOUNT = 0x0200 # 512
UAC_PASSWORD_NEVER_EXPIRES =... |
iCentris/ias_active_directory | lib/ias_active_directory/field_type/binary.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# FieldType Namespace
module FieldType
# Binary Field Type
class Binary
# Encodes a hex string into a GUID
def self.encode(hex_string)
[hex_string].pack('H*')
end
# Decodes a binary GUID ... |
iCentris/ias_active_directory | lib/ias_active_directory/field_type/password.rb | <gh_stars>0
# frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# FieldType Namespace
module FieldType
# Password Field Type
class Password
# Encodes an unencrypted password into an encrypted password
# that the Active Directory server will understand.
d... |
iCentris/ias_active_directory | lib/ias_active_directory/base.rb | <reponame>iCentris/ias_active_directory
# frozen_string_literal: true
# IasActiveDirectory Namespace
module IasActiveDirectory
# Base ancestor for AD Objects
# @!attribute ldap
# The LDAP Connection object
# @!attribute ldap_connected
# Determines if LDAP is connected
# @!attribute caching
# Determ... |
iCentris/ias_active_directory | spec/ias_active_directory_spec.rb | # frozen_string_literal: true
RSpec.describe IasActiveDirectory do
describe 'concerning versioning' do
it 'has a version number' do
expect(IasActiveDirectory::VERSION).to eql('0.1.0')
end
end
describe 'concerning module attributes' do
it 'has an attribute for @special_fields' do
expect {... |
iCentris/ias_active_directory | spec/ias_active_directory/field_type/binary_spec.rb | <filename>spec/ias_active_directory/field_type/binary_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::IasActiveDirectory::FieldType::Binary do
describe 'concerning .encode' do
it 'can encode to string to hex (high nibble first)' do
expect(described_class.encode('DEADBEEF')).to... |
iCentris/ias_active_directory | lib/ias_active_directory/attributes.rb | # frozen_string_literal: true
%w[sam_account_type group_type].each do |file_name|
require 'ias_active_directory/attributes/' + file_name
end
|
iCentris/ias_active_directory | lib/ias_active_directory.rb | # frozen_string_literal: true
require 'ias_active_directory/version'
# External Gem Dependencies
require 'net/ldap'
require 'bindata'
require 'time'
require 'ias_active_directory/sid'
require 'ias_active_directory/base'
require 'ias_active_directory/container'
require 'ias_active_directory/member'
require 'ias_activ... |
iCentris/ias_active_directory | lib/ias_active_directory/field_type/user_dn_array.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# FieldType Namespace
module FieldType
# User DN Array Field Type
class UserDnArray
# Encodes an array of objects into a list of dns
def self.encode(obj_array)
obj_array.collect(&:dn)
end
... |
iCentris/ias_active_directory | spec/ias_active_directory/attributes/sam_account_type_spec.rb | <reponame>iCentris/ias_active_directory
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::IasActiveDirectory::SamAccountType do
describe 'concerning constants' do
it 'knows DOMAIN_OBJECT' do
expect(described_class::DOMAIN_OBJECT).to eql(0x0)
end
it 'knows GROUP_OBJECT' do
... |
iCentris/ias_active_directory | lib/ias_active_directory/field_type/member_dn_array.rb | # frozen_string_literal: true
# IasActiveDirectory namespace
module IasActiveDirectory
# FieldType Namespace
module FieldType
# Member DN Array Field Type
class MemberDnArray
# Encodes an array of objects into a list of dns
def self.encode(obj_array)
obj_array.collect(&:dn)
end
... |
ABAgile/kata-game-of-life | test/game_test.rb | <gh_stars>0
require 'minitest/autorun'
require 'minitest/pride'
require_relative '../lib/game'
describe Game do
end
|
ABAgile/kata-game-of-life | lib/game.rb | # class for Game-of-life simulation
class Game
end
|
TDAF/ansible-consul-template | test/integration/default/serverspec/consul_template_spec.rb | require 'spec_helper'
describe 'Consul Template' do
describe service('consul-template') do
it { should be_enabled }
end
describe file('/opt/consul-template/bin/consul-template') do
it { should be_file }
it { should be_executable }
end
describe file('/opt/consul-template/config/consul-template.c... |
markdrehmann/Hoop-It-Up | app/models/roster.rb | class Roster < ApplicationRecord
has_many :player_rosters
has_many :players, through: :player_rosters
has_many :games
has_many :courts, through: :games
end
|
markdrehmann/Hoop-It-Up | app/controllers/rosters_controller.rb | <gh_stars>1-10
class RostersController < ApplicationController
def edit
roster = Roster.find(params[:id])
if roster.players.include?(current_player)
flash[:error] = "You're already in that game, sucka"
redirect_to games_path
else
roster.players << current_player
flash[:alert] = "Y... |
markdrehmann/Hoop-It-Up | config/routes.rb | Rails.application.routes.draw do
root 'welcome#home'
resources :players, only: [:new, :create, :show]
resources :games, only: [:new, :create, :index, :show]
resources :rosters, only: [:show, :edit]
resources :courts do
resources :games, only: [:new, :index]
end
get '/auth/github/callback' => 'session... |
markdrehmann/Hoop-It-Up | db/migrate/20210213150148_change_day_to_date_time_from_games.rb | <reponame>markdrehmann/Hoop-It-Up
class ChangeDayToDateTimeFromGames < ActiveRecord::Migration[6.1]
def change
change_column :games, :time, :datetime
end
end
|
markdrehmann/Hoop-It-Up | app/controllers/games_controller.rb | <gh_stars>1-10
class GamesController < ApplicationController
def index
if params[:court_id]
@court = Court.find(params[:court_id])
@upcoming_games = Game.upcoming.where(court: @court)
@past_games = Game.past.where(court: @court)
else
@upcoming_games = Game.upcoming
@past_games = ... |
markdrehmann/Hoop-It-Up | db/schema.rb | # 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... |
markdrehmann/Hoop-It-Up | app/controllers/courts_controller.rb | class CourtsController < ApplicationController
def index
@courts = Court.all
# @court = Game.court_with_most_games
end
def new
@court = Court.new
end
def create
@court = Court.new(court_params)
if @court.save
flash[:alert] = "New Court Added"
redirect_to courts_path
else
... |
markdrehmann/Hoop-It-Up | app/controllers/welcome_controller.rb | class WelcomeController < ApplicationController
def home
if logged_in?
redirect_to player_path(current_player)
end
end
end
|
markdrehmann/Hoop-It-Up | app/models/player.rb | class Player < ApplicationRecord
has_secure_password
has_many :player_rosters
has_many :rosters, through: :player_rosters
validates :email, uniqueness: true, presence: true
validates :password, presence: true
validates :name, presence: true
def games
game_array = []
self.rosters.each do |r|
... |
markdrehmann/Hoop-It-Up | config/initializers/time_formats.rb | Time::DATE_FORMATS[:gametime] = '%A, %b %e at %l:%M %P' |
markdrehmann/Hoop-It-Up | app/models/game.rb | class Game < ApplicationRecord
belongs_to :court
belongs_to :roster
validates :court_id, presence: true
validates :roster_id, presence: true
validates :time, presence: true
scope :upcoming, -> { where("time > ?", Time.current).order(:time) }
scope :past, -> { where("time < ?", Time.current).order(:time) }... |
markdrehmann/Hoop-It-Up | app/models/court.rb | <gh_stars>1-10
class Court < ApplicationRecord
has_many :games
has_many :rosters, through: :games
validates :name, presence: true
validates :address, presence: true
end
|
markdrehmann/Hoop-It-Up | app/models/player_roster.rb | class PlayerRoster < ApplicationRecord
belongs_to :player
belongs_to :roster
end
|
markdrehmann/Hoop-It-Up | app/controllers/players_controller.rb | <reponame>markdrehmann/Hoop-It-Up
class PlayersController < ApplicationController
def new
@player = Player.new
end
def create
@player = Player.new(player_params)
if @player.save
session[:player_id] = @player.id
flash[:alert] = "Player Created!"
redirect_to player_path(@player)
... |
markdrehmann/Hoop-It-Up | app/controllers/sessions_controller.rb | class SessionsController < ApplicationController
def login
@player = Player.new
end
def create
auth_hash = request.env["omniauth.auth"]
auth_hash ? login_with_auth(auth_hash) : login
end
def logout
session.clear
redirect_to root_path
end
private
def login_with_auth(auth_hash)
... |
markdrehmann/Hoop-It-Up | db/migrate/20210213162019_remove_day_from_games.rb | class RemoveDayFromGames < ActiveRecord::Migration[6.1]
def change
remove_column :games, :day, :string
end
end
|
markdrehmann/Hoop-It-Up | app/controllers/application_controller.rb | <filename>app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
helper_method :current_player
def current_player
Player.find(session[:player_id]) if logged_in?
end
helper_method :logged_in?
def logged_in?
session[:player_id].present?
end
end
|
michenriksen/nmunch | spec/lib/nmunch/mac_oui_lookup_spec.rb | require 'spec_helper'
describe Nmunch::MacOuiLookup do
context 'when given an Apple mac address' do
it 'returns Apple' do
Nmunch::MacOuiLookup.instance.lookup('58:b0:35:31:33:73').should == 'Apple'
end
end
context 'when given a Cisco mac address' do
it 'returns Cisco Systems' do
Nmunch::... |
michenriksen/nmunch | spec/lib/nmunch/node_spec.rb | <filename>spec/lib/nmunch/node_spec.rb
require 'spec_helper'
describe Nmunch::Node do
subject { Nmunch::Node.new(ip_address: '192.168.0.1', mac_address: 'de:ad:be:ef:de:ad') }
describe '#ip_address' do
it 'returns correct IP address' do
subject.ip_address.should == '192.168.0.1'
end
end
describ... |
michenriksen/nmunch | nmunch.gemspec | # -*- encoding: utf-8 -*-
require File.expand_path('../lib/nmunch/version', __FILE__)
Gem::Specification.new do |gem|
gem.authors = ["<NAME>"]
gem.email = ["<EMAIL>"]
gem.description = %q{Nmunch is a passive network discovery tool that finds live network nodes by analyzing ARP and broadcast packe... |
michenriksen/nmunch | lib/nmunch/subscribers/base.rb | <filename>lib/nmunch/subscribers/base.rb
module Nmunch
module Subscribers
# Public: Base subscriber class
class Base
attr_reader :options
# Public: Initializer
#
# options - A hash of command line options
#
# Returns nothing
def initialize(options)
@options ... |
michenriksen/nmunch | spec/lib/nmunch/report_spec.rb | <filename>spec/lib/nmunch/report_spec.rb
require 'spec_helper'
class TestSubscriber
def process(node); end
end
describe Nmunch::Report do
let(:node) { Nmunch::Node.new(ip_address: '192.168.0.1', mac_address: 'de:ad:be:ef:de:ad') }
let(:options) { {interface: 'en1'} }
let(:subscriber) { TestSubscriber.new }
... |
michenriksen/nmunch | spec/lib/nmunch/subscribers/stdout_spec.rb | <gh_stars>10-100
require 'spec_helper'
describe Nmunch::Subscribers::Stdout do
let(:node) { Nmunch::Node.new(ip_address: '192.168.0.1', mac_address: 'de:ad:be:ef:de:ad') }
let(:options) { {interface: 'en1'} }
subject { Nmunch::Subscribers::Stdout.new(options) }
describe '#process' do
it 'prints node detai... |
michenriksen/nmunch | lib/nmunch/subscribers/stdout.rb | <gh_stars>10-100
module Nmunch
module Subscribers
# Public: Node subscriber to output node details to STDOUT
#
# This subscriber is default and will always be registered
class Stdout < Nmunch::Subscribers::Base
# Public: Process a new node
#
# node - An instance of Nmunch::Node
... |
michenriksen/nmunch | spec/lib/nmunch/subscribers/base_spec.rb | require 'spec_helper'
describe Nmunch::Subscribers::Base do
let(:options) { {interface: 'en1'} }
subject { Nmunch::Subscribers::Base.new(options) }
describe '.initialize' do
it 'assigns options to instance variable' do
subject.options.should == options
end
end
end |
michenriksen/nmunch | lib/nmunch/mac_oui_lookup.rb | require 'singleton'
module Nmunch
# Public: A utility class to look up a MAC address prefix to get the organizational name.
class MacOuiLookup
include Singleton
# Public: Get organizational name for a MAC address
#
# mac_address - A MAC address with format: hh:hh:hh:hh:hh:hh
#
# Example:
... |
michenriksen/nmunch | spec/lib/nmunch/dissectors/base_spec.rb | <filename>spec/lib/nmunch/dissectors/base_spec.rb
require 'spec_helper'
describe Nmunch::Dissectors::Base do
let(:arp_pcap_packet) do
packet = stub(Pcap::Packet)
packet.stub(:raw_data).and_return(ARP_PACKET_DATA)
packet.stub(:ip?).and_return(false)
packet
end
let(:ip_pcap_packet) do
packet =... |
michenriksen/nmunch | lib/nmunch/dissectors/arp.rb | <filename>lib/nmunch/dissectors/arp.rb
module Nmunch
module Dissectors
# Public: Address Resolution Protocol dissector
#
# Extracts IP and MAC address from an ARP packet
#
# See http://en.wikipedia.org/wiki/Address_Resolution_Protocol for protocol details
class Arp < Nmunch::Dissectors::Base
... |
michenriksen/nmunch | spec/lib/nmunch/dissectors/ip_spec.rb | require 'spec_helper'
describe Nmunch::Dissectors::Ip do
let(:ip_pcap_packet) do
packet = stub(Pcap::Packet)
packet.stub(:raw_data).and_return(IP_PACKET_DATA)
packet.stub(:ip?).and_return(true)
packet
end
subject { Nmunch::Dissectors::Ip.new(ip_pcap_packet) }
describe '#ip_address' do
it ... |
michenriksen/nmunch | spec/lib/nmunch_spec.rb | require 'spec_helper'
describe Nmunch do
describe 'PCAP filter expression' do
it 'allows only ARP and broadcast packets' do
Nmunch::CAPTURE_FILTER.should == 'arp or broadcast'
end
end
end |
michenriksen/nmunch | lib/nmunch.rb | require "nmunch/version"
require "nmunch/dissectors/base"
require "nmunch/dissectors/ip"
require "nmunch/dissectors/arp"
require "nmunch/subscribers/base"
require "nmunch/subscribers/stdout"
require "nmunch/node"
require "nmunch/report"
require "nmunch/mac_oui_lookup"
# Public: Main Nmunch module
#
# Acts as a facade ... |
michenriksen/nmunch | lib/nmunch/report.rb | <gh_stars>10-100
module Nmunch
# Public: Nmunch report class
#
# Keeps track of discovered nodes and publishes nodes to registered subscribers
class Report
attr_reader :options
# Public: Initialize a new report
#
# options - Hash of command line options
def initialize(options)
@optio... |
michenriksen/nmunch | lib/nmunch/dissectors/base.rb | <filename>lib/nmunch/dissectors/base.rb
module Nmunch
module Dissectors
# Public: Base dissector class
class Base
attr_reader :pcap_packet, :raw_data
# Public: Initializer
#
# pcap_packet - An instance of Pcap::Packet
#
# Stores the packet and extracts to raw packet data ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.