repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
bolasblack/programr | example.rb | # coding: utf-8
require 'bundler'
Bundler.setup :default
require 'programr'
robot = ProgramR::Facade.new
robot.environment.readonly_tags_file = 'spec/data/readOnlyTags.yaml'
robot.learn ['spec/data']
robot.learn <<-AIML
<category>
<pattern>Hello</pattern>
<template>World</template>
</category>
AIML
whi... |
bolasblack/programr | lib/programr.rb | require 'yaml'
require 'rexml/parsers/sax2parser'
require 'active_support/core_ext/string'
require "programr/version"
require 'programr/graphmaster'
require 'programr/graph_node'
require 'programr/environment'
require 'programr/aiml_elements'
require 'programr/aiml_parser'
require 'programr/history'
require 'programr/... |
bolasblack/programr | spec/aiml_elements_spec.rb | # coding: utf-8
describe ProgramR::ReplaceTag do
let(:robot) { ProgramR::Facade.new }
before do
end
it "can custom gender map" do
robot.learn <<-AIML
<category>
<pattern>gender test</pattern>
<template>
<gender>他和她</gender>
</template>
</category>
AIML
ProgramR::Gender::Map['他和她'] = pr... |
bolasblack/programr | spec/graph_node_spec.rb | require File.join(File.dirname(__FILE__), './utils/fake_graphmaster')
def parse_category category_aiml
history = ProgramR::History.new
environment = ProgramR::Environment.new history
fake_graphmaster = FakeGraphmaster.new
parser = ProgramR::AimlParser.new fake_graphmaster, environment, history
parser.parse c... |
bolasblack/programr | spec/graphmaster_spec.rb | <filename>spec/graphmaster_spec.rb
# coding: utf-8
require File.join(File.dirname(__FILE__), './utils/fake_graphmaster')
describe ProgramR::Graphmaster do
aiml = <<-AIML
<category>
<pattern>test</pattern>
<template>success</template>
</category>
AIML
let(:history) { ProgramR::History.new }
let(:graphmaste... |
chausovSurfStudio/TextFieldsCatalog | TextFieldsCatalog.podspec | Pod::Spec.new do |s|
s.name = "TextFieldsCatalog"
s.version = "0.17.0"
s.summary = "This is catalog of various input field with great opportunities for validation and formatting."
s.homepage = "https://github.com/chausovSurfStudio/TextFieldsCatalog"
s.license = { :type => "MIT", :file => "LICENSE" }
s.aut... |
amckinnell/callgraphy | lib/callgraphy/definition.rb | module Callgraphy
# Exposes a DSL to describe call graphs for a target class.
#
class Definition
attr_reader :registry
def self.register(&block)
definition = Definition.new(Registry.new)
definition.instance_eval(&block)
definition.registry
end
def initialize(registry)
@re... |
amckinnell/callgraphy | sample/rule_service_graph.rb | <reponame>amckinnell/callgraphy
require "callgraphy"
Callgraphy.draw target: "rule_service" do
methods_to_graph :public,
:generate_lot_code => [:generate_lot_code_fragments, :reference_value_for],
:interpret_mfg_date_from_lot => [:earliest_date, :interpret_from]
methods_to_graph :private,
:earliest_da... |
amckinnell/callgraphy | lib/callgraphy/utils.rb | module Callgraphy
# Utility methods.
#
module Utils
def self.pascal_case(snake_case)
snake_case.split("_").map(&:capitalize).join
end
end
end
|
amckinnell/callgraphy | spec/callgraphy_spec.rb | require "spec_helper"
module Callgraphy
RSpec.describe Callgraphy do
let(:registry) { instance_double(Registry) }
describe ".draw" do
it "invokes collaborators" do
expect(Definition).to receive(:register).and_return(registry)
expect(CallGraph).to receive(:draw).with("target", "output",... |
amckinnell/callgraphy | spec/callgraphy/definition_spec.rb | <reponame>amckinnell/callgraphy
require "ruby-graphviz"
require "callgraphy/definition"
module Callgraphy
RSpec.describe Definition do
describe "#define" do
it "saves definition in registry" do
registry = Definition.register do
methods_to_graph :public, m_1: [:m_2]
methods_to_g... |
amckinnell/callgraphy | spec/callgraphy/registry_spec.rb | <filename>spec/callgraphy/registry_spec.rb
require "callgraphy/registry"
module Callgraphy
RSpec.describe Registry do
subject(:registry) { Registry.new }
it "registers public methods" do
registry.register_method(:public, :m_1)
registry.register_method(:public, :m_2)
expect(registry).to ha... |
amckinnell/callgraphy | spec/callgraphy/utils_spec.rb | require "callgraphy/utils"
module Callgraphy
RSpec.describe Utils do
describe "#pascal_case" do
it "converts case" do
expect(Utils.pascal_case("some_name")).to eq("SomeName")
end
end
end
end
|
amckinnell/callgraphy | lib/callgraphy/call_graph.rb | <filename>lib/callgraphy/call_graph.rb
require "ruby-graphviz"
module Callgraphy
# Knows how to graph the target class call graph given the specified registry.
#
class CallGraph
NODE_OPTIONS = {
public: { style: "filled", fillcolor: "palegreen" },
private: {},
callers: { style: "filled", fi... |
amckinnell/callgraphy | spec/callgraphy/call_graph_spec.rb | require "callgraphy/call_graph"
module Callgraphy
RSpec.describe CallGraph do
let(:registry) { instance_double(Registry) }
it "draws a graph" do
configure_registry(
public_methods: ["m_1"],
private_methods: ["m_2", "m_3"],
callers: ["c_1"],
dependencies: ["c_2"],
... |
amckinnell/callgraphy | callgraphy.gemspec | <reponame>amckinnell/callgraphy
lib = File.expand_path("../lib", __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "callgraphy/version"
Gem::Specification.new do |spec|
spec.name = "callgraphy"
spec.version = Callgraphy::VERSION
spec.authors = ["<NAME>"]
spec.email ... |
amckinnell/callgraphy | lib/callgraphy/registry.rb | <gh_stars>0
module Callgraphy
# Records the information that describes a call graph.
#
class Registry
def initialize
@registry = { public: [], private: [], callers: [], dependencies: [], calls: [] }
end
def register_method(scope, caller)
@registry.fetch(scope).push(caller.to_s)
end
... |
amckinnell/callgraphy | lib/callgraphy.rb | require "callgraphy/call_graph"
require "callgraphy/definition"
require "callgraphy/registry"
require "callgraphy/utils"
require "callgraphy/version"
# Provides a DSL for creating call graphs for a target class.
#
module Callgraphy
def self.draw(target:, output_directory: ".", &block)
CallGraph.draw(target, outp... |
amckinnell/callgraphy | spec/spec_helper.rb | # Right at the top so we don't miss any opportunities to track coverage.
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
end
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "callgraphy"
|
andrewkww/shopify_app | lib/shopify_app/version.rb | <reponame>andrewkww/shopify_app<filename>lib/shopify_app/version.rb
# frozen_string_literal: true
module ShopifyApp
VERSION = '13.0.1'
end
|
andrewkww/shopify_app | lib/shopify_app/engine.rb | # frozen_string_literal: true
module ShopifyApp
class Engine < Rails::Engine
engine_name 'shopify_app'
isolate_namespace ShopifyApp
initializer "shopify_app.assets.precompile" do |app|
app.config.assets.precompile += %w[
shopify_app/redirect.js
shopify_app/top_level.js
shopi... |
andrewkww/shopify_app | lib/shopify_app/session/jwt.rb | # frozen_string_literal: true
module ShopifyApp
class JWT
def initialize(token)
@token = token
set_payload
end
def shopify_domain
payload && dest_host
end
def shopify_user_id
payload && payload['sub']
end
private
def payload
return unless @payload
... |
andrewkww/shopify_app | lib/shopify_app/test_helpers/all.rb | <reponame>andrewkww/shopify_app
require 'shopify_app/test_helpers/webhook_verification_helper'
|
andrewkww/shopify_app | test/shopify_app/session/jwt_test.rb | <gh_stars>0
# frozen_string_literal: true
require 'test_helper'
module ShopifyApp
class JWTTest < ActiveSupport::TestCase
TEST_SHOPIFY_DOMAIN = 'https://test.myshopify.io'
TEST_SANITIZED_SHOPIFY_DOMAIN = 'test.myshopify.io'
TEST_USER_ID = 'test-user'
setup do
ShopifyApp.configuration.api_key =... |
JJ/markup | lib/github/markup.rb | <filename>lib/github/markup.rb
begin
require "linguist"
rescue LoadError
# Rely on extensions instead.
end
require "github/markup/command_implementation"
require "github/markup/gem_implementation"
module GitHub
module Markups
# all of supported markups:
MARKUP_ASCIIDOC = :asciidoc
MARKUP_CREOLE = :c... |
leodsgn/gymintel | app/models/user.rb | # frozen_string_literal: true
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable,
:validatable, :confirmable, :o... |
leodsgn/gymintel | app/models/body_group.rb | <gh_stars>1-10
# frozen_string_literal: true
class BodyGroup < ApplicationRecord
end
|
leodsgn/gymintel | db/migrate/20180627201336_add_information_to_user.rb | <gh_stars>1-10
class AddInformationToUser < ActiveRecord::Migration[5.2]
def change
add_column :users, :first_name, :string, null: false
add_column :users, :last_name, :string, null: false
add_column :users, :birth_date, :date
add_column :users, :phone_number, :string, limit: 20
add_column :users,... |
doamatto/nano | nano.gemspec | <gh_stars>1-10
# frozen_string_literal: true
Gem::Specification.new do |spec|
spec.name = "nano-theme"
spec.version = "0.5.2"
spec.authors = ["doamatto"]
spec.email = ["<EMAIL>"]
spec.summary = "Nano is a super lightweight Jekyll theme built to work great on all platforms, respect user privacy, and load at l... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/Occupancy_Simulator_Office/measure.rb | <gh_stars>10-100
# *** Copyright Notice ***
# OS Measures Copyright (c) 2018, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of any required
# approvals from the U.S. Dept. of Energy). All rights reserved.
# If you have questions about your rights ... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/Occupancy_Simulator_Office/resources/UserLibrary.rb | <reponame>benlellouch/AlphaBuilding-SyntheticDataset<gh_stars>10-100
# *** Copyright Notice ***
# OS Measures Copyright (c) 2018, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of any required
# approvals from the U.S. Dept. of Energy). All rights r... |
benlellouch/AlphaBuilding-SyntheticDataset | code/create_workflow.rb | # MIT License
#
# Copyright (c) [2021]
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, d... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/ExportMetertoCSV/tests/ExportMetertoCSV_test.rb | <reponame>benlellouch/AlphaBuilding-SyntheticDataset
require 'openstudio'
require 'openstudio/ruleset/ShowRunnerOutput'
require 'minitest/autorun'
require 'fileutils'
require_relative '../measure.rb'
class ExportOutputMetertoCSV_Test < MiniTest::Test
def model_path
return "#{File.dirname(__FILE__)}/example_mo... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/AddOutputVariable/measure.rb | <gh_stars>10-100
#see the URL below for information on how to write OpenStuido measures
# http://openstudio.nrel.gov/openstudio-measure-writing-guide
#see the URL below for access to C++ documentation on mondel objects (click on "model" in the main window to view model objects)
# http://openstudio.nrel.gov/sites/opens... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/update_hvac_setpoint_schedule/Gaussian_Random.rb |
class RandomGaussian
def initialize(mean = 0.0, sd = 1.0, range = lambda { Kernel.rand })
@mean, @sd, @range = mean, sd, range
@next_pair = false
end
def rand
if (@next_pair = !@next_pair)
# Compute a pair of random values with normal distribution.
# See http://en.wikipedia.org/wiki/Box-... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/ExportVariabletoCSV/measure.rb | require 'erb'
require 'csv'
#start the measure
class ExportVariabletoCSV < OpenStudio::Ruleset::ReportingUserScript
# human readable name
def name
return "ExportVariabletoCSV"
end
# human readable description
def description
return "Exports an OutputVariable specified in the AddOutputVariable OpenS... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/update_hvac_setpoint_schedule/measure.rb | # insert your copyright here
# see the URL below for information on how to write OpenStudio measures
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/
# start the measure
class UpdateHVACSetpointSchedule < OpenStudio::Measure::ModelMeasure
@@heating_summer_design_t = 15.56
@@... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/add_demand_controlled_ventilation/measure.rb | # insert your copyright here
# see the URL below for information on how to write OpenStudio measures
# http://nrel.github.io/OpenStudio-user-documentation/reference/measure_writing_guide/
# start the measure
class AddDemandControlledVentilation < OpenStudio::Measure::ModelMeasure
# Standard space types for office r... |
benlellouch/AlphaBuilding-SyntheticDataset | code/OpenStudio-measures/Occupancy_Simulator_Office/tests/test.rb | # *** Copyright Notice ***
# OS Measures Copyright (c) 2018, The Regents of the University of California,
# through Lawrence Berkeley National Laboratory (subject to receipt of any required
# approvals from the U.S. Dept. of Energy). All rights reserved.
# If you have questions about your rights to use or distrib... |
sferik/rainbow | lib/rainbow.rb | require 'rainbow/global'
require 'rainbow/legacy'
require 'rainbow/ext/string'
module Rainbow
def self.new
Wrapper.new(global.enabled)
end
self.enabled = false unless STDOUT.tty? && STDERR.tty?
self.enabled = false if ENV['TERM'] == 'dumb'
self.enabled = true if ENV['CLICOLOR_FORCE'] == '1'
# On Win... |
sferik/rainbow | lib/rainbow/version.rb | <reponame>sferik/rainbow
module Rainbow
VERSION = "1.99.1".freeze
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/review_dates_controller.rb | <filename>app/controllers/admin/review_dates_controller.rb
module Admin
class ReviewDatesController < BaseController
def new
end
# TODO: will_paginate?
def index
@past_dates = ReviewDate.past
@upcoming_dates = ReviewDate.upcoming
end
def show
@review_date = ReviewDate.inclu... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160510163519_add_unique_condition_to_review_dates_and_groups.rb | <gh_stars>0
class AddUniqueConditionToReviewDatesAndGroups < ActiveRecord::Migration
def change
add_index :review_dates, [:review_group_id, :exercise_id], unique: true
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160508230109_add_length_to_review_date.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class AddLengthToReviewDate < ActiveRecord::Migration
def change
add_column :review_dates, :length_in_minutes, :integer, null: false, default: 10
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151126170255_add_review_points.rb | class AddReviewPoints < ActiveRecord::Migration
def change
add_column :apps, :review_points, :integer, default: 0, null: false
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/students_controller.rb | module Admin
class StudentsController < BaseController
def show
@students = current_course.students.includes(:apps)
@exercise_ids = ExercisePointMaster.new(current_course).exercise_ids
end
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/models/user/appraisal.rb | class User < ActiveRecord::Base
class Appraisal
attr_accessor :user, :course
def initialize(user, course: Courses.current)
@user = user
@course = course
end
def percentage
[ 100 * user.total_points.to_f/course.total_points.to_f, 100].min.round
end
GRADES = {
(0...5... |
HTW-Webtech/ai-webtech-admin-app | app/models/email/review_dates_mailer.rb | module Email
class ReviewDatesMailer
attr_accessor :review_date
def initialize(review_date:)
@review_date = review_date
end
def subject
"Neuer CodeReview-Termin am #{formatted_date}"
end
def message
"Es wurde gerade für die #{exercise_id}te Aufgabe ein neuer CodeReview-Tem... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151125045822_remove_app_id_from_name.rb | class RemoveAppIdFromName < ActiveRecord::Migration
class App < ActiveRecord::Base
end
def up
remove_index :apps, :name
App.find_each do |app|
next unless !!app.name.match(/\d+-\w+/)
app.update! name: app.name.match(/\d-(.+)/)[1]
end
end
def down
add_index :apps, :name, unique: ... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160413150840_add_summer2016_group.rb | class AddSummer2016Group < ActiveRecord::Migration
def up
ss2016 = Group.create(name: 'SS2016')
User.where('created_at > ?', [3.weeks.ago]).each do |user|
ss2016.users << user
end
end
def down
Group.where(name: 'SS2016').delete_all
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151011104841_create_exercise_results.rb | class CreateExerciseResults < ActiveRecord::Migration
def change
create_table :exercise_results do |t|
t.integer :app_id, null: false
t.integer :exercise_id, null: false
t.integer :failures_count, null: false, default: -1
t.timestamps null: false
end
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/models/app.rb | require 'securerandom'
class App < ActiveRecord::Base
validates :user, presence: true
validates :external_url, url: true, allow_blank: true
belongs_to :user
has_many :exercise_results
has_one :feedback
def self.for_permalink_or_id(permalink_or_id)
id = permalink_or_id.to_s.split('-').first
find(i... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/emails_controller.rb | <filename>app/controllers/admin/emails_controller.rb
module Admin
class EmailsController < BaseController
def new
end
def create
scheduler = Email::Scheduler.new(
group: group_or_review_group!,
subject: email_params[:subject],
body: email_params[:body]
)
if sched... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160420185752_fix_winter_course_user.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class FixWinterCourseUser < ActiveRecord::Migration
def up
winter = Group.where(name: 'Winter2015').first
winter.users = User.where('created_at < ?', [10.weeks.ago])
end
def down
# noop
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160504172614_add_course_to_app.rb | <gh_stars>0
class AddCourseToApp < ActiveRecord::Migration
def up
add_column :apps, :course, :string
App.includes(:user).find_each do |app|
app.update course: app.user.course
end
change_column :apps, :course, :string, null: false
end
def down
remove_column :apps, :course, :string
end
... |
HTW-Webtech/ai-webtech-admin-app | app/models/user/app_limit.rb | class User < ActiveRecord::Base
module AppLimit
module_function
def limit_reached?(user, course = Courses.current)
return false if user.admin?
# TODO: Attach course to the user!
user.apps.count >= course.exercises.count
end
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20150918074851_create_apps.rb | class CreateApps < ActiveRecord::Migration
def change
create_table :apps do |t|
t.string :name, null: false
t.string :ssh_key, null: false
t.string :pg_host, default: 'localhost', null: false
t.string :pg_database, null: false
t.string :pg_login, null: false
... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160512074845_add_slot_to_review_group.rb | class AddSlotToReviewGroup < ActiveRecord::Migration
def change
add_column :review_groups, :order, :integer, default: 0, null: false
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/apiv1/exercise_results_controller.rb | module Apiv1
class ExerciseResultsController < BaseController
def create
exercise_result = json_body['exercise_result']
if exercise_result['success'] == true
app = App.for_permalink_or_id(exercise_result['app_name'])
exercise_id = exercise_result['exercise_id'].to_i
result = Ex... |
HTW-Webtech/ai-webtech-admin-app | spec/models/app_spec.rb | require 'rails_helper'
describe App do
subject { described_class.new(id: 1, name: 'funny-capybara') }
describe '#public_url' do
before do
allow(subject).to receive(:cc).with(:site).and_return(double('Site', app_hostname: 'foo.bar'))
end
it 'returns the correct url' do
expect(subject.publi... |
HTW-Webtech/ai-webtech-admin-app | app/models/courses/winter2015.rb | <gh_stars>0
module Courses
class Winter2015 < Base
def self.exercises
{
1 => [ 2, Date.new(2015, 11, 27) ],
2 => [ 2, Date.new(2015, 11, 24) ],
3 => [ 4, Date.new(2015, 12, 14) ],
4 => [ 2, Date.new(2016, 1, 12) ],
5 => [ 0, Date.current ],
}
end
def se... |
HTW-Webtech/ai-webtech-admin-app | spec/factories/app_factory.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
FactoryGirl.define do
factory :app do
name { AppName.generate_unique }
association :user
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/base_controller.rb | <filename>app/controllers/admin/base_controller.rb
module Admin
class BaseController < ::ApplicationController
before_action :authenticate_user!
before_action :redirect_non_admin_user
before_action :set_current_course
private
def set_current_course
if current_course = params[:current_cours... |
HTW-Webtech/ai-webtech-admin-app | app/models/notifier.rb | <filename>app/models/notifier.rb
class Notifier
def self.notifier
@notifier ||= Slack::Notifier.new ENV.fetch('SLACK_WEBHOOK_URL'),
channel: '#app-notifications',
username: 'app-bot'
end
def self.notify(message)
return unless Rails.env.production?
notifier.ping... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160403171727_prefill_timestamp_columns_for_users.rb | class PrefillTimestampColumnsForUsers < ActiveRecord::Migration
def up
execute <<-SQL
UPDATE users SET
created_at = '2015-10-01 12:00:00',
updated_at = '2015-10-01 12:00:00'
SQL
change_column :users, :created_at, :datetime, null: false
change_column :users, :updated_at, :datetim... |
HTW-Webtech/ai-webtech-admin-app | app/validators/url_validator.rb | <gh_stars>1-10
class UrlValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << (options[:message] || "must be a valid URL") unless url_valid?(value)
end
# a URL may be technically well-formed but may
# not actually be valid, so this checks for both.
... |
HTW-Webtech/ai-webtech-admin-app | app/models/courses/base.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
module Courses
class Base
def self.exercises
{ 1 => [ 2, Date.current ] }
end
def self.exercise_names_with_review
ids = review_points.select { |_, points| points.max > 0 }.map(&:first)
exercise_names.select { |exercise_id, _| ids.include?(exerc... |
HTW-Webtech/ai-webtech-admin-app | spec/factories/exercise_result_factory.rb | FactoryGirl.define do
factory :exercise_result do
association :app
exercise_id 1
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/mailers/application_mailer.rb | class ApplicationMailer < ActionMailer::Base
default from: "no-reply@#{cc(:site).hostname}"
def sent_email(email:, subject:, body:, bcc: '')
mail to: email, bcc: bcc, subject: subject, body: body, layout: 'email/base'
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/models/exercise_result.rb | class ExerciseResult < ActiveRecord::Base
belongs_to :app
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160420111351_rename_course_groups.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class RenameCourseGroups < ActiveRecord::Migration
def up
Group.where(name: 'SS2016').update_all(name: 'Summer2016')
Group.where(name: 'WS2015').update_all(name: 'Winter2015')
end
def down
Group.where(name: 'Summer2016').update_all(name: 'SS2016')
Group.... |
HTW-Webtech/ai-webtech-admin-app | app/models/statistics/students_points.rb | <filename>app/models/statistics/students_points.rb
# Point-Overview for all students
# students.each do |student|
# points["exercises"]["1"]["students"][student.id]["total_points"] => 6
# points["exercises"]["1"]["students"][student.id]["review_points"] => 2
# points["exercises"]["1"]["students"][student.id]["tes... |
HTW-Webtech/ai-webtech-admin-app | spec/models/app_name_spec.rb | <filename>spec/models/app_name_spec.rb
require 'rails_helper'
RSpec.describe AppName do
describe '.generate_unique' do
it 'creates a name beginning with the probably upcoming sequential id' do
expect(described_class.generate_unique).to match /.+-.+/
end
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151126172142_migrate_already_reviewed_apps.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class MigrateAlreadyReviewedApps < ActiveRecord::Migration
def up
execute <<-SQL
UPDATE apps
SET review_points = 2
WHERE reviewed_at IS NOT NULL
SQL
end
def down
execute <<-SQL
UPDATE apps SET review_points = 0
SQL
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/users/sessions_controller.rb | class Users::SessionsController < Devise::SessionsController
# POST /resource/sign_in
def create
if logged_in_user_blocked?
env['warden'].logout
redirect_to '/', alert: 'You account is blocked and you can not login anymore.'
else
super
end
end
private
def logged_in_user_blo... |
HTW-Webtech/ai-webtech-admin-app | app/models/exercise.rb | class Exercise
def self.generate_next_id(user)
user.app_count + 1
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/groups_controller.rb | <filename>app/controllers/admin/groups_controller.rb
module Admin
class GroupsController < BaseController
def show
@group = Group.find(params[:id])
end
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151111193830_drop_index_from_app_names.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class DropIndexFromAppNames < ActiveRecord::Migration
def up
remove_index :apps, :name
end
def down
add_index "apps", ["name"], name: "index_apps_on_name", unique: true, using: :btree
end
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160510142749_add_review_state_to_review_date.rb | class AddReviewStateToReviewDate < ActiveRecord::Migration
def change
add_column :review_dates, :reviewed_at, :datetime
add_column :review_dates, :review_points, :integer, default: 0, null: false
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/models/app_name.rb | class AppName
PREFIX = %w(
cherry alluring swift woopy sharp speedy wonky
rocky cleary flashy snowy sweet sour angry
funny silent crazy happy fluffy huge tiny mad
loopy janky wild erratic funky kinky unique
prominent rare spiky wise odd splendid
)
NAMES = %w(
blossom hound boar archid bah... |
HTW-Webtech/ai-webtech-admin-app | spec/models/exercise_point_master_spec.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
require 'rails_helper'
# TODO: Fix tests
RSpec.describe ExercisePointMaster do
let(:course) do
Module.new do
module_function
def exercises
{
1 => [ 2, Date.new(2015, 11, 27)],
2 => [ 4, Date.new(2015, 12, 14)],
}
en... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/home_controller.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class HomeController < ::ApplicationController
end
|
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160506135459_add_external_hosting_to_apps.rb | class AddExternalHostingToApps < ActiveRecord::Migration
def change
add_column :apps, :external_hosting, :boolean, default: false
add_column :apps, :external_url, :string
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/models/email/app_points_mailer.rb | module Email
class AppPointsMailer
attr_accessor :app, :points
def initialize(app:, points:)
@app = app
@points = points
end
def subject
"#{points} Punkt(e) für App: #{app.permalink}"
end
def body
"Es wurden gerade für deine App #{app.permalink} #{points} Punkte im A... |
HTW-Webtech/ai-webtech-admin-app | app/models/apiv1/client_auth.rb | require 'openssl'
module Apiv1
class ClientAuth
attr_reader :instance
def initialize
@instance = CipherBase64::Instance.new(auth_files_path)
end
def valid?(signature_base64, data)
instance.valid?(signature_base64, data)
end
def auth_files_path
Rails.root + "config/apiv1-a... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/base_controller.rb | <filename>app/controllers/base_controller.rb
class BaseController < ::ApplicationController
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_action :authenticate_user!
before_action :redirect_users_to_users_name... |
HTW-Webtech/ai-webtech-admin-app | app/models/email/scheduler.rb | module Email
class Scheduler
attr_accessor :group, :subject, :body, :mails
def initialize(group:, subject:, body:)
@group = group
@subject = subject
@body = body
end
def run
self.mails = group.users.map do |user|
ApplicationMailer.sent_email(
email: user.ema... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151127041253_drop_postgress_feature.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
class DropPostgressFeature < ActiveRecord::Migration
def up
remove_column :apps, :pg_host
remove_column :apps, :pg_database
remove_column :apps, :pg_login
remove_column :apps, :pg_passwd
end
def down
add_column :apps, :pg_host, :string, default: 'loc... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/application_controller.rb | class ApplicationController < ActionController::Base
force_ssl if: :ssl_configured?
before_action :authorize_mini_profiler
private
def authorize_mini_profiler
if current_user && current_user.admin?
Rack::MiniProfiler.authorize_request
end
end
def ssl_configured?
Rails.env.production?
e... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160508205029_add_review_groups.rb | <gh_stars>0
class AddReviewGroups < ActiveRecord::Migration
def change
create_table :review_groups do |t|
t.timestamps
end
create_table :review_dates do |t|
t.integer :review_group_id, null: false
t.datetime :begins_at, null: false
t.integer :exercise_id, null: false
t.times... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/apps_controller.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
module Admin
class AppsController < BaseController
def create
apps = Courses.current.apps
apps.find_each do |app|
ArisService.publish(app)
end
redirect_to root_path, notice: "Recreated the apps.yml file for #{apps.count} Apps."
end
... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160422182348_add_course_to_user.rb | class AddCourseToUser < ActiveRecord::Migration
def up
add_column :users, :course, :string
%w(Summer2016 Winter2015).each do |course|
group = Group.where(name: course).first!
group.users.each do |user|
user.update course: course
end
end
end
def down
remove_column :users,... |
HTW-Webtech/ai-webtech-admin-app | app/helpers/feedbacks_helper.rb | <filename>app/helpers/feedbacks_helper.rb
module FeedbacksHelper
EXERCISE_TEMPLATES = {
8 => <<-EOF.strip_heredoc
# Bewertung Abschlussprojekt: PatMan
| Feature | Punkte: Erreicht/Von | Feedback |
|----------------------------------------|
| CRUD Patient | ?/3 | |
|---------------------------... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160403171845_block_all_old_users.rb | <filename>db/migrate/20160403171845_block_all_old_users.rb
class BlockAllOldUsers < ActiveRecord::Migration
def up
execute <<-SQL
UPDATE users SET
blocked_at = '#{Time.current}'
WHERE
created_at < '2016-01-01 00:00'
AND name != 'admin'
SQL
end
def down
execute <<-S... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/admin/jenkins_controller.rb | module Admin
class JenkinsController < BaseController
def create
apps = Courses.current.apps
JenkinsService.publish(apps)
redirect_to root_path, notice: "Recreated jenkins_yaml for #{apps.count} apps."
end
def update
app = App.for_permalink_or_id(params[:id])
JenkinsService.... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20151123093912_replace_exercise_passed_on_apps_with_points.rb | class ReplaceExercisePassedOnAppsWithPoints < ActiveRecord::Migration
def up
remove_column :apps, :exercise_passed_at
add_column :apps, :exercise_points, :integer, default: 0
end
def down
add_column :apps, :exercise_passed_at, :datetime
remove_column :apps, :exercise_points
end
end
|
HTW-Webtech/ai-webtech-admin-app | app/controllers/review_groups_controller.rb | <gh_stars>0
class ReviewGroupsController < ::BaseController
def show
@review_group = current_user.review_group
end
def update
review_group = current_user.review_group
review_group.update review_group_params
redirect_to :back, notice: 'Einstellungen aktualisiert'
end
private
def review_gro... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/users_controller.rb | class UsersController < ::BaseController
def show
@announcements = Announcement.all
@user = fetch_user
@apps = @user.apps.order(id: :asc)
@course = Courses.current
end
def edit
@user = fetch_user
end
def update
@user = fetch_user
if @user.update_attributes(user_params)
redi... |
HTW-Webtech/ai-webtech-admin-app | app/controllers/apiv1/base_controller.rb | <reponame>HTW-Webtech/ai-webtech-admin-app
module Apiv1
class BaseController < ::ApplicationController
AuthError = Class.new(Exception)
# before_action :authenticate_client
rescue_from AuthError, with: :handle_auth_error
private
def authenticate_client
sign = request.headers['x-client-aut... |
HTW-Webtech/ai-webtech-admin-app | db/migrate/20160808080030_create_feedbacks.rb | <reponame>HTW-Webtech/ai-webtech-admin-app<filename>db/migrate/20160808080030_create_feedbacks.rb
class CreateFeedbacks < ActiveRecord::Migration
def change
create_table :feedbacks do |t|
t.text :body
t.references :app
t.timestamps null: false
end
add_foreign_key :feedbacks, :apps
end... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.