repo_name
stringlengths 6
97
| path
stringlengths 3
341
| text
stringlengths 8
1.02M
|
|---|---|---|
aks/validate_suffixed_number
|
spec/rails_helper.rb
|
<reponame>aks/validate_suffixed_number
# rails_helper.rb
|
aks/validate_suffixed_number
|
spec/validate_suffixed_number_spec.rb
|
<reponame>aks/validate_suffixed_number<filename>spec/validate_suffixed_number_spec.rb
# frozen_string_literal: true
require 'validate_suffixed_number'
require 'pry-byebug'
RSpec.describe ValidateSuffixedNumber do
context "methods" do
subject { ValidateSuffixedNumber }
it { is_expected.to respond_to(:parse_numeric_option,
:parse_integer_option,
:parse_number,
:parse_integer)
}
end
describe ".parse_numeric_option" do
let(:method) { :parse_numeric_option }
before(:all) do
@options = {}
@options2 = {}
end
def validated_number(arg)
@options[:arg] = arg.to_s
ValidateSuffixedNumber.parse_numeric_option(:arg, @options, "Bad data")
end
def validated_number_with_whitespace(arg)
@options2[:arg] = " #{arg} "
ValidateSuffixedNumber.parse_numeric_option(:arg, @options2, "Bad data")
end
context "when given good arguments" do
[
['1.2G' , 1_200_000_000 ],
['900M', 900_000_000 ],
['650K', 650_000 ],
[ '120', 120 ],
['500m', 500_000_000 ],
['175k', 175_000 ],
['175 K', 175_000 ],
['175 thousand', 175_000 ],
['225g', 225_000_000_000 ],
['225 billion', 225_000_000_000 ],
['-1.2G', -1_200_000_000 ],
['-900M', -900_000_000 ],
['+650K', 650_000 ],
['-120', -120 ],
['-500m', -500_000_000 ],
['+ 175k', 175_000 ],
['- 225g', -225_000_000_000 ],
['- 763 million', -763_000_000 ],
['- 763 M', -763_000_000 ],
[' 2.3 trillion', 2_300_000_000_000 ],
['-4.2 hundred', -420 ],
['+ 2.9 T', 2_900_000_000_000 ],
['+ 4.86 P', 4_860_000_000_000_000 ],
['+ 4.86 quadrillion', 4_860_000_000_000_000 ],
['+123.4E6', 123_400_000.0 ], # exponentials
['-3.852E-6', -0.00000385_200 ],
['486E', 486_000_000_000_000_000_000 ], # etabyte (non-exponentials)
['2.39 Z', 2_390_000_000_000_000_000_000 ], # zetabyte
['5.4 Y', 5_400_000_000_000_000_000_000_000 ],
].each do |arg, expected_value|
it "should produce the correct result" do
@options[:arg] = arg.to_s
expect(validated_number(arg)).to eq expected_value.to_f
end
it "should update the options hash also" do
@options[:arg] = arg.to_s
expect { validated_number(arg) }.to change { @options[:arg] }.from(arg).to(expected_value.to_f)
end
it "should ignore the whitespace around the number" do
@options2[:arg] = " #{arg} "
expect(validated_number_with_whitespace(arg)).to eq expected_value.to_f
end
end
end
context "when given bad or arguments" do
subject { ValidateSuffixedNumber.parse_numeric_option(:arg, @options, error_msg) }
let(:error_msg) { "Bad data" }
context "with no argument" do
it "should show an error" do
@options = { arg: nil }
expect { subject }.to raise_error(ArgumentError, /No value/)
end
end
context "with a bad argment" do
it "should show an error" do
@options = { arg: "fuh" }
expect { subject }.to raise_error(ArgumentError, /#{error_msg}/)
end
end
context "with no explicit error message" do
let(:error_msg) { nil }
it "should show the default error message" do
@options = { arg: "fuh" }
expect { subject }.to raise_error(ArgumentError, /Bad value for/)
end
end
end
end
describe ".parse_number" do
def validated_number(arg)
ValidateSuffixedNumber.parse_number(arg.to_s)
end
def validated_number_with_whitespace(arg)
ValidateSuffixedNumber.parse_number(' ' + arg.to_s + ' ')
end
def validated_number_with_fraction(arg, fraction)
numstr = arg.to_s.sub(/(\D)$/, "#{fraction}\1")
ValidateSuffixedNumber.parse_number(numstr)
end
context "when given good data" do
[
['123B', 123_000_000_000],
['123G', 123_000_000_000],
['456M', 456_000_000],
['789K', 789_000],
['12.3B', 12_300_000_000],
['45.6M', 45_600_000],
['78.9', 78.9],
['12.3', 12.3]
].each do |arg, expected_value|
it "should produce the correct result" do
expect(validated_number(arg)).to eq expected_value.to_f
end
it "should ignore the whitespace around the number" do
expect(validated_number_with_whitespace(arg)).to eq expected_value.to_f
end
end
it "should manage plain numbers correctly" do
expect(ValidateSuffixedNumber.parse_number('1')).to eq 1
expect(ValidateSuffixedNumber.parse_number('12')).to eq 12
expect(ValidateSuffixedNumber.parse_number('123')).to eq 123
expect(ValidateSuffixedNumber.parse_number('1234')).to eq 1_234
expect(ValidateSuffixedNumber.parse_number('12345')).to eq 12_345
end
it "should handle both lower and upper case suffixes" do
expect(ValidateSuffixedNumber.parse_number('12.3b')).to eq 12_300_000_000
expect(ValidateSuffixedNumber.parse_number('1.23g')).to eq 1_230_000_000
expect(ValidateSuffixedNumber.parse_number('45.6m')).to eq 45_600_000
expect(ValidateSuffixedNumber.parse_number('7.89k')).to eq 7_890
expect(ValidateSuffixedNumber.parse_number('78.9K')).to eq 78_900
expect(ValidateSuffixedNumber.parse_number('12.3M')).to eq 12_300_000
end
it "should handle suffixes with a leading whitespace" do
expect(ValidateSuffixedNumber.parse_number('12.3 b')).to eq 12_300_000_000
expect(ValidateSuffixedNumber.parse_number('1.23 g')).to eq 1_230_000_000
expect(ValidateSuffixedNumber.parse_number('45.6 m')).to eq 45_600_000
expect(ValidateSuffixedNumber.parse_number('7.89 k')).to eq 7_890
expect(ValidateSuffixedNumber.parse_number('78.9 K')).to eq 78_900
expect(ValidateSuffixedNumber.parse_number('12.3 M')).to eq 12_300_000
end
end
context "when given no data" do
it "should return a nil" do
expect(ValidateSuffixedNumber.parse_number(nil)).to eq nil
end
end
context "when given bad data" do
it "should return a nil" do
expect(ValidateSuffixedNumber.parse_number('feh')).to eq nil
end
end
end
describe ".parse_integer" do
let(:method) { :parse_integer }
context "when given good arguments" do
it "should truncate floats to integers" do
expect(ValidateSuffixedNumber.parse_integer('78.9')).to eq 78
expect(ValidateSuffixedNumber.parse_integer('12.3')).to eq 12
end
it "should properly parse integers" do
expect(ValidateSuffixedNumber.parse_integer('123')).to eq 123
expect(ValidateSuffixedNumber.parse_integer('1234')).to eq 1_234
expect(ValidateSuffixedNumber.parse_integer('12345')).to eq 12_345
end
context "when given no data" do
it "should return a nil" do
expect(ValidateSuffixedNumber.parse_integer('')).to eq nil
end
end
context "when given bad data" do
it "should return a nil" do
expect(ValidateSuffixedNumber.parse_integer('gronk!')).to eq nil
end
end
end
end
end
|
lz1irq/hacktues
|
db/seeds.rb
|
User.create!(name: "<NAME>",
email: "<EMAIL>",
password: "<PASSWORD>",
password_confirmation: "<PASSWORD>",
admin: true,
activated: true,
activated_at: Time.zone.now,
number: 15,
klas: 8,
section: 'A')
User.create!(name: "Example User",
email: "<EMAIL>",
password: "<PASSWORD>",
password_confirmation: "<PASSWORD>",
activated: true,
activated_at: Time.zone.now,
number: 1,
klas: 1,
section: 'A')
99.times do |n|
name = Faker::Name.name
email = "<EMAIL>"
password = "password"
User.create!(name: name,
email: email,
password: password,
password_confirmation: password,
activated: true,
activated_at: Time.zone.now,
number: 1,
klas: 1,
section: 'A')
end
|
lz1irq/hacktues
|
db/migrate/20150929102550_add_day1_day2_day2_current_presence_to_user.rb
|
<reponame>lz1irq/hacktues
class AddDay1Day2Day2CurrentPresenceToUser < ActiveRecord::Migration
def change
add_column :users, :day1, :bool
add_column :users, :day2, :bool
add_column :users, :day3, :bool
add_column :users, :current_presence, :bool
end
end
|
lz1irq/hacktues
|
db/schema.rb
|
<gh_stars>0
# 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 source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151009100838) do
create_table "articles", force: :cascade do |t|
t.string "title"
t.string "content"
t.boolean "published"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "friendly_id_slugs", force: :cascade do |t|
t.string "slug", null: false
t.integer "sluggable_id", null: false
t.string "sluggable_type", limit: 50
t.string "scope"
t.datetime "created_at"
end
add_index "friendly_id_slugs", ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true
add_index "friendly_id_slugs", ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type"
add_index "friendly_id_slugs", ["sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_id"
add_index "friendly_id_slugs", ["sluggable_type"], name: "index_friendly_id_slugs_on_sluggable_type"
create_table "invites", force: :cascade do |t|
t.integer "from_id"
t.integer "to_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
create_table "pages", force: :cascade do |t|
t.string "title"
t.text "content"
t.boolean "published", default: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "slug"
t.boolean "in_nav", default: false
end
add_index "pages", ["slug"], name: "index_pages_on_slug", unique: true
create_table "teams", force: :cascade do |t|
t.string "name"
t.integer "captain_id"
t.text "members_id"
t.string "project_name"
t.text "project_desc"
t.text "technologies"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.integer "room"
end
# Could not dump table "users" because of following NoMethodError
# undefined method `[]' for nil:NilClass
end
|
lz1irq/hacktues
|
app/models/invite.rb
|
class Invite < ActiveRecord::Base
end
|
lz1irq/hacktues
|
app/controllers/sessions_controller.rb
|
class SessionsController < ApplicationController
def new
end
def create_base
user = User.find_by(email: params[:session][:email].downcase)
if user && user.authenticate(params[:session][:password])
if user.activated?
log_in user
params[:session][:remember_me] == '1' ? remember(user) : forget(user)
return user
else
message = "Неактивиран акаунт. "
message += "Провери си пощата за линк за активация."
flash[:warning] = message
#redirect_to root_url
return "unactivated"
end
else
flash.now[:danger] = "Невалидни email и/или парола"
return false
#render 'new'
end
end
def create
user = create_base
case user
when User
redirect_back_or user
when "unactivated"
redirect_to root_url
when false
render 'new'
end
end
def create_remote
user = create_base
case user
when User
team = get_team(user)
result = {"team" => team, "user" => user}
render :json => result
else
render "wrong user data"
end
end
def destroy
log_out if logged_in?
redirect_to root_url
end
private
def get_team(user)
begin
team = Team.find(user.team_id)
rescue ActiveRecord::RecordNotFound
team = false
end
return team
end
end
|
lz1irq/hacktues
|
test/helpers/application_helper_test.rb
|
<reponame>lz1irq/hacktues
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test "full title helper" do
assert_equal full_title, "HackTUES"
assert_equal full_title("Foo"), "Foo | HackTUES"
end
end
|
lz1irq/hacktues
|
db/migrate/20150914101629_add_number_to_user.rb
|
class AddNumberToUser < ActiveRecord::Migration
def change
add_column :users, :number, :integer
end
end
|
lz1irq/hacktues
|
db/migrate/20151008212344_add_room_to_team.rb
|
<reponame>lz1irq/hacktues
class AddRoomToTeam < ActiveRecord::Migration
def change
add_column :teams, :room, :integer
end
end
|
lz1irq/hacktues
|
db/migrate/20150914104347_add_klas_to_user.rb
|
class AddKlasToUser < ActiveRecord::Migration
def change
add_column :users, :klas, :integer
end
end
|
lz1irq/hacktues
|
app/models/presence.rb
|
class Presence < ActiveRecord::Base
end
|
lz1irq/hacktues
|
db/migrate/20150822140718_create_teams.rb
|
<reponame>lz1irq/hacktues<gh_stars>0
class CreateTeams < ActiveRecord::Migration
def change
create_table :teams do |t|
t.string :name
t.integer :captain_id
t.text :members_id
t.string :project_name
t.text :project_desc
t.text :technologies
t.timestamps null: false
end
end
end
|
lz1irq/hacktues
|
test/controllers/static_pages_controller_test.rb
|
require 'test_helper'
class StaticPagesControllerTest < ActionController::TestCase
test "should get home" do
get :home
assert_response :success
assert_select "title", full_title
end
end
|
lz1irq/hacktues
|
app/controllers/pages_controller.rb
|
class PagesController < ApplicationController
before_action :logged_in_user, only: [:new, :edit]
before_action :admin_user, only: [:create, :new, :edit, :update, :destroy]
def show
get_page
# Check if page is published or allow viewing if user is admin
unless (@page && @page.published?) || (current_user && current_user.admin)
flash[:warning] = "Страницата не е намерена."
redirect_to root_url
return
end
end
def new
@page = Page.new
end
def create
@page = Page.new(page_params)
if @page.save
flash[:success] = "Успешно създаване на страницата."
redirect_to "/#{@page.slug}"
else
render 'new'
end
end
def edit
get_page
end
def update
get_page
@page.slug = nil
if @page.update_attributes(page_params)
flash[:success] = "Успешно обновяване на страницата."
redirect_to "/#{@page.slug}"
else
render 'edit'
end
end
def destroy
Page.friendly.find(params[:id]).destroy
flash[:success] = "Страница изтрита."
redirect_to root_url
end
private
def page_params
params.require(:page).permit(:title, :content, :in_nav, :published)
end
# Confirms a logged-in user.
def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Влез в профила си."
redirect_to login_url
end
end
def get_page
begin
@page = Page.friendly.find(params[:id])
rescue ActiveRecord::RecordNotFound
flash[:warning] = "Страницата не е намерена."
redirect_to root_url
return
end
end
# Confirms an admin user.
def admin_user
redirect_to(root_url) unless current_user.admin?
end
end
|
lz1irq/hacktues
|
config/routes.rb
|
Rails.application.routes.draw do
root 'static_pages#home'
get 'help' => 'static_pages#help'
get 'about' => 'static_pages#about'
get 'team' => 'static_pages#team'
get 'signup' => 'users#new'
get 'login' => 'sessions#new'
post 'login' => 'sessions#create'
post 'login/remote' => 'sessions#create_remote'
delete 'logout' => 'sessions#destroy'
resources :users
get 'users/:id/check' => 'users#check'
get 'users/:id/declaration' => 'users#declaration'
resources :account_activations, only: [:edit]
resources :password_resets, only: [:new, :create, :edit, :update]
resources :teams
patch 'team.:id' => 'teams#update'
resources :pages, only: [:new, :create, :edit, :update,
:destroy]
resources :articles
get 'teams/:id/leave' => 'teams#leave'
get 'invites/send' => 'teams#send_invite'
get 'invites/cancel' => 'teams#cancel_invite'
get 'invites/accept' => 'teams#accept_invite'
get 'invites/decline' => 'teams#decline_invite'
get '/:id' => 'pages#show'
end
|
lz1irq/hacktues
|
app/models/page.rb
|
<gh_stars>0
class Page < ActiveRecord::Base
extend FriendlyId
friendly_id :title, use: [:slugged, :history]
validates :title, presence: true, length: { minimum: 3, maximum: 50 }
validates :content, presence: true, length: { minimum: 42 }
def normalize_friendly_id(text)
text.to_slug.normalize(transliterations: :bulgarian).to_s
end
end
|
lz1irq/hacktues
|
app/controllers/teams_controller.rb
|
class TeamsController < ApplicationController
before_action :logged_in_user, only: [:edit, :update, :destroy]
# before_action :correct_user, only: :destroy
def index
@teams = Team.paginate(page: params[:page]).order('name ASC')
end
def show
@team = Team.find(params[:id])
@captain = User.find(@team.captain_id)
@members = @team.members_id
end
def new
@team = Team.new
end
def create
@team = Team.new(team_params)
@team.update(captain_id: session[:user_id])
params[:team][:technologies] = params[:team][:technologies].split("\n")
User.find(@team.captain_id).update(team_id: @team.id)
if @team.save
@team.update(technologies: params[:team][:technologies])
flash[:success] = "Успешно създаден отбор."
redirect_to "/teams/#{@team.id}"
else
render 'new'
end
end
def send_invite
@invite = Invite.new(invite_params)
if @invite.save
flash[:success] = "Успешно поканен участник."
redirect_to User.find(params[:to_id])
else
redirect_to root
end
end
def cancel_invite
Invite.find_by(from_id: params[:from_id], to_id: params[:to_id]).destroy
flash[:success] = "Успешно отменена покана."
redirect_to User.find(params[:to_id])
end
def accept_invite
@sending_user = User.find(params[:from_id])
@accepting_user = User.find(params[:to_id])
@accepting_user.update(team_id: @sending_user.team_id)
@team = Team.find(@sending_user.team_id)
@members = @team.members_id
@members.push(@accepting_user.id)
@team.update(members_id: @members)
Invite.find_by(from_id: params[:from_id], to_id: params[:to_id]).destroy
flash[:success] = "Успешно приета покана."
redirect_to User.find(params[:to_id])
end
def decline_invite
Invite.find_by(from_id: params[:from_id], to_id: params[:to_id]).destroy
flash[:success] = "Успешно отказана покана."
redirect_to User.find(params[:to_id])
end
def leave
@user = current_user
@team = Team.find(params[:id])
@user.update(team_id: nil)
@new_members = @team.members_id - [@user.id]
@team.update(members_id: @new_members)
flash[:success] = "Успешно напускане на отбор."
redirect_to @user
end
def destroy
@team = Team.find(params[:id])
User.find(@team.captain_id).update(team_id: nil)
@members = @team.members_id
@members.each do |id|
User.find(id).update(team_id: nil)
end
@team.destroy
flash[:success] = "Отбор изтрит."
redirect_to teams_path
end
def edit
@team = Team.find(params[:id])
end
def update
@team = Team.find(params[:id])
if current_user.admin?
if @team.update(room: params[:team][:room])
flash[:success] = "Успешно обновяване на стая."
redirect_to "/teams/#{@team.id}"
end
else
params[:team][:technologies] = params[:team][:technologies].split("\n")
if @team.update_attributes(team_params)
@team.update(technologies: params[:team][:technologies])
flash[:success] = "Успешно обновяване на отбора."
redirect_to "/teams/#{@team.id}"
else
render 'edit'
end
end
end
private
def team_params
params.require(:team).permit(:name, :project_name, :project_desc,
:captain_id, :members_id)
end
def invite_params
params.permit(:from_id, :to_id)
end
# Before filters
# Confirms a logged-in user.
def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Влез в профила си."
redirect_to login_url
end
end
# Confirms the correct user.
# def correct_user
# @user = User.find(params[:id])
# redirect_to(root_url) unless @user.id == current_team.captain_id
# end
# Confirms an admin user.
def admin_user
redirect_to(root_url) unless current_user.admin?
end
end
|
lz1irq/hacktues
|
app/models/team.rb
|
<gh_stars>0
class Team < ActiveRecord::Base
serialize :members_id, Array
serialize :technologies, Array
validates :name, presence: true, length: { maximum: 50 }
validates :project_desc, presence: true, length: { minimum: 50, maximum: 500 }
validates :technologies, length: { maximum: 10 }
validates :members_id, length: { maximum: 4 }
end
|
lz1irq/hacktues
|
app/controllers/users_controller.rb
|
<gh_stars>0
require 'rqrcode'
class UsersController < ApplicationController
before_action :logged_in_user, only: [:new, :create, :edit, :show, :update, :destroy, :check]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: [:new, :create, :destroy, :check, :declaration]
def index
@users = User.paginate(page: params[:page]).order('name ASC')
@participant_count = User.all.count - User.where(admin: true).size
@checked_count = User.where(current_presence: true).count
end
def check
@user = User.find(params[:id])
@day = Date.current.inspect.split(' ').second.to_i
# change to @day == 9 before start of hackathon
if (@day == 9)
@user.update(day1: true)
elsif (@day == 10)
@user.update(day2: true)
elsif (@day == 11)
@user.update(day3: true)
end
@user.update(current_presence: false) if @user.current_presence == nil
@user.update(current_presence: !@user.current_presence)
flash[:success] = "Успешно чекиране на участник."
redirect_to user_path
end
def declaration
@user = User.find(params[:id])
@user.update(declaration: false) if @user.declaration == nil
@user.update(declaration: !@user.declaration)
flash[:success] = "Успешно отбелязване на декларация."
redirect_to user_path
end
def show
@user = User.find(params[:id])
if @user == current_user && @user.team_id == nil
@invites = Invite.where(to_id: @user.id)
if @invites.any?
@invites.each do |invite|
@from_user = User.find(invite.from_id)
@from_team = Team.find(@from_user.team_id)
flash.now[:info] = "Покана от #{@from_user.name} за #{@from_team.name}
<a href='/invites/accept?from_id=#{invite.from_id}&to_id=#{invite.to_id}'>
<span class='label label-success'>Приеми</span>
</a>
<a href='/invites/decline?from_id=#{invite.from_id}&to_id=#{invite.to_id}'>
<span class='label label-danger'>Откажи</span>
</a>".html_safe
end
end
end
@current_user_team = Team.where(captain_id: current_user.id)
get_team
@invite = Invite.where(from_id: current_user.id, to_id: params[:id])
@barcode = RQRCode::QRCode.new(user_url + "/check", size: 8, level: :h)
end
def new
@user = User.new
end
def create
@user = User.new(user_params)
if @user.save
@user.send_activation_email
flash[:info] = "Провери си пощата за линк за активация."
redirect_to root_url
else
render 'new'
end
end
def edit
end
def update
if @user.update_attributes(user_params)
flash[:success] = "Успешно обновяване на профила."
redirect_to @user
else
render 'edit'
end
end
def destroy
User.find(params[:id]).destroy
flash[:success] = "Участник изтрит."
redirect_to users_url
end
private
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation,
:number, :klas, :section,
:day1, :day2, :day3,
:current_presence)
end
# Before filters
# Confirms a logged-in user.
def logged_in_user
unless logged_in?
store_location
flash[:danger] = "Влез в профила си."
redirect_to login_url
end
end
# Confirms the correct user.
def correct_user
@user = User.find(params[:id])
redirect_to(root_url) unless current_user?(@user)
end
# Confirms an admin user.
def admin_user
redirect_to(root_url) unless current_user.admin?
end
def get_team
begin
@team = Team.find(@user.team_id)
rescue ActiveRecord::RecordNotFound
@team = false
return
end
end
end
|
thedavidharris/blindside
|
Blindside.podspec
|
<filename>Blindside.podspec
Pod::Spec.new do |s|
s.name = "Blindside"
s.version = "1.3.1"
s.summary = "Blindside provides dependency injection capabilities for Objective-C on iOS and OS X"
s.homepage = "https://github.com/jbsf/blindside"
s.license = 'MIT'
s.author = { "<NAME>" => "<EMAIL>" }
s.source = { :git => "https://github.com/jbsf/blindside.git", :tag => "v1.3.1" }
s.requires_arc = true
s.ios.deployment_target = '5.0'
s.osx.deployment_target = '10.7'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.source_files = "Sources/Blindside/**/*.{h,m}"
s.public_header_files = "Sources/Blindside/include/*.h"
end
|
tomwillfixit/blog
|
files/ec2-metadata-service.rb
|
#!/usr/bin/env ruby
require 'sinatra'
require 'sinatra/reloader'
require 'socket'
require 'ipaddr'
require 'inifile'
require 'time'
require 'tilt/erb'
set :bind, ENV['BIND_ADDR'] || '169.254.169.254'
set :port, '80'
creds_file = '/opt/aws/credentials'
docker_range = IPAddr.new('172.17.42.1/16')
get '/latest/meta-data/local-ipv4' do
if ENV['LOCAL_ADDR']
ENV['LOCAL_ADDR']
else
ipv4 = (Socket.ip_address_list.select { |a| a.ipv4_private? && !(docker_range === a.ip_address) }).last
ipv4.ip_address
end
end
get '/latest/meta-data/' do
'ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
hostname
iam/
instance-action
instance-id
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
services/'
end
get '/latest/dynamic/instance-identity/document' do
'
{
"devpayProductCodes" : null,
"privateIp" : "10.64.01.100",
"availabilityZone" : "us-west-2",
"version" : "2010-08-31",
"region" : "us-west-2",
"instanceId" : "i-0123456",
"billingProducts" : null,
"instanceType" : "t2.micro",
"accountId" : "12345678",
"architecture" : "x86_64",
"kernelId" : null,
"ramdiskId" : null,
"imageId" : "ami-d2dswedsd",
"pendingTime" : "2017-09-04T11:51:29Z"
}'
end
get '/latest/meta-data/mac' do
'tom-test-mac'
end
get '/latest/meta-data/network/interfaces/macs/tom-test-mac/subnet-id' do
'subnet-b'
end
get '/latest/meta-data/network/interfaces/macs/tom-test-mac/security-group-ids' do
'
sg-0
sg-5
sg-6'
end
get '/latest/meta-data/local-hostname' do
`hostname`
end
get '/latest/meta-data/instance-id' do
'tom-test-instance'
end
get '/latest/meta-data/ami-id' do
'tom-test-ami-id'
end
get '/latest/meta-data/iam/security-credentials/' do
'default'
end
get '/latest/meta-data/iam/security-credentials/:role' do
if File.file?(creds_file)
inifile = IniFile.load(creds_file)
if inifile.has_section?('default')
aws_credentials = {
code: 'Success',
last_updated: Time.now.utc.iso8601,
type: 'AWS-HMAC',
access_key_id: inifile['default']['aws_access_key_id'],
secret_access_key: inifile['default']['aws_secret_access_key'],
token: '',
expiration: (Time.now.utc + 31622400).iso8601
}
render_credentials(aws_credentials)
else
halt 500, 'The AWS credentials file must have a default section'
end
else
halt 500, "The AWS credentials file must be located at #{creds_file}"
end
end
def render_credentials(creds)
erb :credentials, locals: creds
end
__END__
@@ credentials
{
"Code": "<%= code %>",
"LastUpdated": "<%= last_updated %>",
"Type": "<%= type %>",
"AccessKeyId": "<%= access_key_id %>",
"SecretAccessKey": "<%= secret_access_key %>",
"Token": "<%= token %>",
"Expiration": "<%= expiration %>"
}
|
omhmichaels/homebrew-cask
|
Casks/samsung-dex.rb
|
cask "samsung-dex" do
version "20210720162553369"
sha256 "5110f7be08f6d43d9cd1229dbbe33bbd34e35da13a5c6ce7e724ac7904dfbeba"
url "https://downloadcenter.samsung.com/content/SW/#{version[0..5]}/#{version}/SamsungDeXSetup.dmg"
name "Samsung DeX"
desc "Extend some Samsung devices into a desktop-like experience"
homepage "https://www.samsung.com/us/explore/dex/"
livecheck do
url "https://www.samsung.com/global/download/SamsungDeXMac"
strategy :header_match
regex(%r{(\d+)/SamsungDeXSetup\.dmg}i)
end
pkg "Install Samsung DeX.pkg"
uninstall pkgutil: [
"com.samsung.pkg.dexonpc",
"com.samsung.pkg.mss_connectivity2",
"com.samsung.pkg.ssud",
]
caveats do
kext
reboot
end
end
|
omhmichaels/homebrew-cask
|
Casks/resolume-arena.rb
|
<filename>Casks/resolume-arena.rb
cask "resolume-arena" do
version "7.6.0,79034"
sha256 "0f61caf84684e615819a369a30d5e999f094d0987662a842550121118e23c381"
url "https://resolume.com/download/Resolume_Arena_#{version.major_minor_patch.dots_to_underscores}_rev_#{version.after_comma}_Installer.dmg"
name "Resolume Arena"
desc "Video mapping software"
homepage "https://resolume.com/"
livecheck do
url "https://resolume.com/download/"
strategy :page_match do |page|
page.scan(/href=.*?Arena[._-]v?(\d+(?:[._-]\d+)+)[._-]rev[._-](\d+).+\.dmg/i)
.map { |match| "#{match[0].tr("_", ".")},#{match[1]}" }
end
end
pkg "Resolume Arena Installer.pkg"
uninstall pkgutil: [
"com.resolume.pkg.ResolumeArena.*",
"com.resolume.pkg.ResolumeDXV",
"com.resolume.pkg.ResolumeQuickLook",
"com.resolume.pkg.ResolumeAlley",
"com.resolume.pkg.ResolumeWireNodes",
"com.resolume.pkg.ResolumeCommon",
"com.resolume.pkg.ResolumeWire",
],
delete: "/Applications/Resolume Arena #{version.major}",
signal: ["TERM", "com.resolume.arena"],
launchctl: "com.resolume.arena"
zap pkgutil: [
"com.resolume.pkg.ResolumeDXV",
"com.resolume.pkg.ResolumeQuickLook",
]
end
|
omhmichaels/homebrew-cask
|
Casks/private-internet-access.rb
|
cask "private-internet-access" do
version "3.1-06756"
sha256 "dc8ff76085d4ef634f201bb9ab08db2450b7b4adabcb5be6a03261dcc60d8d6e"
url "https://installers.privateinternetaccess.com/download/pia-macos-#{version}.zip"
name "Private Internet Access"
desc "VPN client"
homepage "https://www.privateinternetaccess.com/"
livecheck do
url "https://www.privateinternetaccess.com/installer/x/download_installer_osx"
regex(/pia-macos-(\d+(?:.\d+)*)\.zip/i)
end
auto_updates true
depends_on macos: ">= :high_sierra"
installer script: {
executable: "Private Internet Access Installer.app/Contents/Resources/vpn-installer.sh",
sudo: true,
}
uninstall script: {
executable: "/Applications/Private Internet Access.app/Contents/Resources/vpn-installer.sh",
args: ["uninstall"],
sudo: true,
}
zap trash: [
"~/Library/Application Support/com.privateinternetaccess.vpn",
"~/Library/LaunchAgents/com.privateinternetaccess.vpn",
"~/Library/Preferences/com.privateinternetaccess.vpn",
"~/Library/Preferences/com.privateinternetaccess.vpn.plist",
]
end
|
omhmichaels/homebrew-cask
|
Casks/futurerestore-gui.rb
|
cask "futurerestore-gui" do
version "1.93"
sha256 "a873f5c9f7befe67a47987e11ffbcf845998e002cd551833f5c37cff8c7581bd"
url "https://github.com/CoocooFroggy/FutureRestore-GUI/releases/download/v#{version}/FutureRestore-GUI-Mac-#{version}.dmg"
name "FutureRestore GUI"
desc "Graphical interface for FutureRestore"
homepage "https://github.com/CoocooFroggy/FutureRestore-GUI/"
app "FutureRestore GUI.app"
zap trash: [
"~/FutureRestoreGUI/extracted/",
"~/FutureRestoreGUI/preferences.properties",
"~/FutureRestoreGUI/*.tar.xz",
]
end
|
omhmichaels/homebrew-cask
|
Casks/couchbase-server-community.rb
|
<reponame>omhmichaels/homebrew-cask<filename>Casks/couchbase-server-community.rb
cask "couchbase-server-community" do
version "7.0.1"
sha256 "3f87d678782f12b2b4338315aaa3da6466601f07fcff6317b7b5a453c2b61eb2"
url "https://packages.couchbase.com/releases/#{version}/couchbase-server-community_#{version}-macos_x86_64.dmg"
name "Couchbase Server"
desc "Distributed NoSQL cloud database"
homepage "https://www.couchbase.com/"
livecheck do
url "http://appcast.couchbase.com/membasex.xml"
strategy :sparkle
end
conflicts_with cask: "couchbase-server-enterprise"
app "Couchbase Server.app"
end
|
omhmichaels/homebrew-cask
|
Casks/trezor-suite.rb
|
cask "trezor-suite" do
arch = Hardware::CPU.intel? ? "x64" : "arm64"
version "21.10.2"
url "https://suite.trezor.io/web/static/desktop/Trezor-Suite-#{version}-mac-#{arch}.dmg"
if Hardware::CPU.intel?
sha256 "f2043d03f8bd71373f09634cedf44425702398b3453ab6d541683a8accd58d2a"
else
sha256 "5a7eeac02cfa9efa4fb411b49cbe1fe7a763e8e1f043a300def1532d4da836da"
end
name "TREZOR Suite"
desc "Companion app for the Trezor hardware wallet"
homepage "https://suite.trezor.io/"
livecheck do
url :homepage
regex(/Trezor-Suite-(\d+(?:\.\d+)*)-/i)
end
app "Trezor Suite.app"
zap trash: [
"~/Library/Application Support/@trezor/suite-desktop",
"~/Library/Preferences/io.trezor.TrezorSuite.plist",
]
end
|
omhmichaels/homebrew-cask
|
Casks/selfcontrol.rb
|
cask "selfcontrol" do
version "4.0.1"
sha256 "fbefdca70944bb2578d06ee449195b0e7d0de0026f4f670701e8632b299c833f"
url "https://downloads.selfcontrolapp.com/SelfControl-#{version}.zip"
name "SelfControl"
desc "Block your own access to distracting websites"
homepage "https://selfcontrolapp.com/"
livecheck do
url :homepage
regex(%r{href=.*?/SelfControl[._-](\d+(?:\.\d+)*)\.zip}i)
end
auto_updates true
app "SelfControl.app"
zap trash: "~/Library/Preferences/org.eyebeam.SelfControl.plist"
end
|
omhmichaels/homebrew-cask
|
Casks/uninstallpkg.rb
|
cask "uninstallpkg" do
version "1.2.0,1512"
sha256 "1997d5ad61b809cc656214e7277d12e016bf6004b5ae04f241e0aa93d1814620"
url "https://www.corecode.io/downloads/uninstallpkg_#{version.before_comma}.zip"
name "UninstallPKG"
desc "PKG software package uninstall tool"
homepage "https://www.corecode.io/uninstallpkg/"
livecheck do
url "https://www.corecode.io/uninstallpkg/uninstallpkg.xml"
strategy :sparkle
end
depends_on macos: ">= :mojave"
app "UninstallPKG.app"
uninstall delete: "/Library/PrivilegedHelperTools/com.corecode.UninstallPKGDeleteHelper",
launchctl: "com.corecode.UninstallPKGDeleteHelper"
zap trash: [
"~/Library/Application Support/UninstallPKG",
"~/Library/Preferences/com.corecode.UninstallPKG.plist",
"~/Library/Saved Application State/com.corecode.UninstallPKG.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/videofusion.rb
|
cask "videofusion" do
version "2.2.0.2988.0"
sha256 "b732c465ba06a661a22be13947aaf1a4669c105ad97d2971ac9dc6ae1e104318"
url "https://lf3-faceucdn-tos.pstatp.com/obj/faceu-packages/Jianying_#{version.dots_to_underscores}.dmg",
verified: "lf3-faceucdn-tos.pstatp.com/obj/faceu-packages/"
name "VideoFusion"
name "剪映专业版"
desc "Video editor"
homepage "https://lv.ulikecam.com/"
livecheck do
url "https://lf3-beecdn.bytetos.com/obj/ies-fe-bee/bee_prod/biz_80/bee_prod_80_bee_publish_3563.json"
strategy :page_match do |page|
JSON.parse(page)["mac_download_pkg"]["channel_default"][/(\d+(?:_\d+)+)\.dmg/i, 1].tr("_", ".")
end
end
depends_on macos: ">= :mojave"
app "VideoFusion-macOS.app"
zap trash: [
"~/Library/Caches/com.lemon.ee.lv",
"~/Library/Preferences/com.lemon.ee.lv.plist",
"~/Library/Saved Application State/com.lemon.ee.lv.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/jupyterlab.rb
|
cask "jupyterlab" do
version "3.1.18-1"
sha256 "6502077f70dcf9a92617a1beb7c721b54aa6e7ed601713762a3226dd854ae176"
url "https://github.com/jupyterlab/jupyterlab_app/releases/download/v#{version}/JupyterLab-Setup-macOS.pkg"
name "JupyterLab App"
desc "Desktop application for JupyterLab"
homepage "https://github.com/jupyterlab/jupyterlab_app"
pkg "JupyterLab-Setup-macOS.pkg"
uninstall pkgutil: [
"com.electron.jupyterlabapp",
"com.electron.jupyterlab-desktop",
],
delete: [
"/Applications/JupyterLab.app",
]
zap trash: [
"~/Library/Application Support/jupyterlab_app",
"~/Library/Logs/JupyterLab",
"~/Library/Logs/jupyterlab_app",
"~/Library/Preferences/com.electron.jupyterlabapp.plist",
"~/Library/Saved Application State/com.electron.jupyterlabapp.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/libreoffice-language-pack.rb
|
<filename>Casks/libreoffice-language-pack.rb
cask "libreoffice-language-pack" do
arch = Hardware::CPU.intel? ? "x86-64" : "aarch64"
folder = Hardware::CPU.intel? ? "x86_64" : "aarch64"
version "7.2.2"
if Hardware::CPU.intel?
language "af" do
sha256 "2469d035ce2f17d57af8c4c6102e96101b3be7bb5b2ab7c32ff762b7772de363"
"af"
end
language "am" do
sha256 "4396f54eaaa70918b7858daa317187e759e0a65a88bb96b63cf84bc532f83917"
"am"
end
language "ar" do
sha256 "ec359cc3265bda4b4dd88f6611672a492ee69f9b98a81931611ccc06177670a6"
"ar"
end
language "as" do
sha256 "9f1325584d4cb23229630059c596e2c0d0a405fc203b1307c0cdb186e08adeba"
"as"
end
language "be" do
sha256 "7bc0f8aca120d64135a45f77579aac21211ee6f023cf947ccf8bc8aae1bc0527"
"be"
end
language "bg" do
sha256 "40336e358f7fae1f721e9106795ec2597697973aa680b2dca542d2807395c19d"
"bg"
end
language "bn-IN" do
sha256 "e7b419034fd90b7f20c67a73ac8a5916d61d3d169bbbbc615cbe23614e841128"
"bn-IN"
end
language "bn" do
sha256 "b8c239f556527553f30b4e6290883530f351fdfaaf0005ce1fdda03e2f2bf06b"
"bn"
end
language "bo" do
sha256 "7d2240480abc34326304af1e744a92e16511f56dcbeae2adea49f635876c0662"
"bo"
end
language "br" do
sha256 "a9ce960e8805adbddd2c7df40990110c4fa4f63b1d0cbee6c2ac2c77d4f6ae19"
"br"
end
language "bs" do
sha256 "d1a02bb4c25ea141098fea813476c5aab424aa1d003033737b8b4e2a30079ea6"
"bs"
end
language "ca" do
sha256 "5494550865335108dacef8302d8b3823e86714e3fc3f80a3101ca2e10fea79f3"
"ca"
end
language "cs" do
sha256 "32013d1ae2950436576bc543d07c5d2a72ed43e801a8674dccaf78807d13a590"
"cs"
end
language "cy" do
sha256 "af011916d5184ea7c4239443f945ff3b0408fc73533f97b1133cbe17487e5a9d"
"cy"
end
language "da" do
sha256 "cfe488e528be891cf4e26008123965032a5a92146ed0004cc3027ed7aca234db"
"da"
end
language "de" do
sha256 "1451dd1917677c42c2eea6ffd4c0018f1bdaa08ceb0aefeb606ae721230dc332"
"de"
end
language "dz" do
sha256 "de213de9857a936f8a1fa795e583467e6ce6302dc9b1af305df3078bf27a29f9"
"dz"
end
language "el" do
sha256 "a7ba1bd0a7b75d1cccb82e10141f77c899aea5b15e745feaeb2e11249850f207"
"el"
end
language "en-GB", default: true do
sha256 "d05a192f6cbcd3b84e0f8933deb4eda73ab0a2b548e5148daffa37d14e37c7b2"
"en-GB"
end
language "en-ZA" do
sha256 "f56ede30e265fbf60537c147b2f5417957a3123abb6e2c3968c038f7d0e0d648"
"en-ZA"
end
language "eo" do
sha256 "4bbffd981a83491b8aa6314f0476b2f330627b8f1556afd3bae67b35a232fe67"
"eo"
end
language "es" do
sha256 "25209c05378399d36e6ff897b620fb83df8ace8842ca1efeeba0d00da140b825"
"es"
end
language "et" do
sha256 "b41f5fed488c0b4fbf068cb1072d94fc6ba6c068498340282ff5aec903dd2961"
"et"
end
language "eu" do
sha256 "c219db96d19191a10b5595563d1200ec63719263b97d9660d0e05fd5269ea170"
"eu"
end
language "fa" do
sha256 "06dc151db98a436d5478a0762cc71a26fe94419d0b3c45b4cfee7a1556cce734"
"fa"
end
language "fi" do
sha256 "82cb3dd513cad09023cb6df36b345d93443b5af189758e99e50a883fd57f47eb"
"fi"
end
language "fr" do
sha256 "8b89bf83dc03f2538b43b84e847cae5858d87d3f64c6548c3dd7273f74ff872b"
"fr"
end
language "fy" do
sha256 "d518f2a0bd703fdd66e5f8b16b871ed105a91a4380b0a2c088a1a6a08fd4f799"
"fy"
end
language "ga" do
sha256 "975cf891d0f05386a5e1edb708f8459eb9a97a57b91e8f6899410c10f6255325"
"ga"
end
language "gd" do
sha256 "a7659dcc6c6436946de9e07a6b022ec8a2224432449985caaf4513883fb66853"
"gd"
end
language "gl" do
sha256 "8885e30850aab68bd67847aab58af762a29752fbe5858a72920bdd624cd67220"
"gl"
end
language "gu" do
sha256 "15cf81bc7ec965dad9cb20e5f83f7f0038754c05553e5ddbed637616dfbb906c"
"gu"
end
language "he" do
sha256 "4409e9ed4c2875379558db1e658e07de7bae3f2a22376707b796f78e81fddc1d"
"he"
end
language "hi" do
sha256 "bc1b18ce8429c16f56f460472a2d0d9787d883d9b6c96d7d8cbb3b2d9ddc8929"
"hi"
end
language "hr" do
sha256 "19f108ec4f61ca95bc4d2708d9d76366b7ef21b0d4531016d37d486fb214f2e0"
"hr"
end
language "hu" do
sha256 "6ddfcbf41b0192acebb9ca1689cd42e215eba22fd332aaec286f54ee149f9684"
"hu"
end
language "id" do
sha256 "f6b0f3f6d69dde362f39a836dbfe3f99396bb58a0b5237ca7eb7667cd7c30c3c"
"id"
end
language "is" do
sha256 "0e839e0e138446b8365816c33eb6dae84ee8f7294518723d4f98d4a9a849aa7f"
"is"
end
language "it" do
sha256 "4a8f3c176b0d22438c4e12dd83d9df5b1fe943391094b8c9f68fc0daa4b3c1fa"
"it"
end
language "ja" do
sha256 "76d91e56fb4a0af60d85ab258b1ee2e33d2b80b88c62883e173fd978ec815bc1"
"ja"
end
language "ka" do
sha256 "dcac179efb9dab21cdf74ff2ba3fc89baae3181671d7a97c7148c121b08eb5e7"
"ka"
end
language "kk" do
sha256 "3baf8ca23e1dd323bba4f20d604ec5606aac56a8ba174fda320ad826bf32c83d"
"kk"
end
language "km" do
sha256 "ddf526696b159fb27e17bc0f017a630c9feb2e2336a45cd5450a1c57e0826dde"
"km"
end
language "kn" do
sha256 "870b97ca2a601825317498ee5c22a2863fcaade8c1a78b0d25b3ec9a8cbd3d99"
"kn"
end
language "ko" do
sha256 "451ba46a289ffa7a307cb52063f5dcf96dd2eef6d2a1c8caddb7718e05f77ace"
"ko"
end
language "ks" do
sha256 "7bbae1085bb769edce915dba1502297a9f99f784023b51e2a575aa0eacf5e03e"
"ks"
end
language "lb" do
sha256 "4a5b011e1add79ac876d1c2cb1109c110a84cd688554e7c1df45c3d14a80614e"
"lb"
end
language "lo" do
sha256 "8450e8e92c778cb09e2e009217b1a2d6472b0fe8eaebadee76d8e07058998127"
"lo"
end
language "lt" do
sha256 "60b79b86fc8f915e203515673acd320771107041964de7634dc5d7cfd500fbb9"
"lt"
end
language "lv" do
sha256 "2cacdaa6e4cf8beb58b0cb4677206c7a7611fbc4e48b59769adf289688e35365"
"lv"
end
language "mk" do
sha256 "e4b8ad68ee05935190a755db5648baa07ffccecdeaa7f9319a439d635dc0735f"
"mk"
end
language "ml" do
sha256 "5ef14874df2a9f0fd8f20745c70293817ee2f6d818980c8f3da0899058c28ed6"
"ml"
end
language "mn" do
sha256 "bd9ae00f39b7e012f46d8b3e4f98714d6074bfad247c245f93baeed7e3cb0f8c"
"mn"
end
language "mr" do
sha256 "75492113d15a550ea9fa60f6d8e70ba6e8c97f649c5aa5918d626974db3178d7"
"mr"
end
language "my" do
sha256 "6a648d149b2c2250ac2bbd8c44b38318474e79a2211be827870a3aa6404b6b1e"
"my"
end
language "nb" do
sha256 "b39bd9b026821287bee15b2ed49166be465b8f36284660c0581a9eb39fe4a1ef"
"nb"
end
language "ne" do
sha256 "443fa0bcedcf961b0321e2d63febc19ec3a61454cfa3d9adacc929f20e669d21"
"ne"
end
language "nl" do
sha256 "29e315bd5aad707a01c682e57c3954c49a2e9ea51a514a1987ddf92d111c5993"
"nl"
end
language "nn" do
sha256 "0bd9abee73b21209f7d6228c846de08545e305c2a97ae14a99a8549428c66471"
"nn"
end
language "nr" do
sha256 "9274de4d60122edef2c4c2002b6619db442d87c8d98df07ea44d98c0c6661156"
"nr"
end
language "oc" do
sha256 "1a72f20639780a27ad68ce357c7d83d8ec176bbcdaa724901bafb885226a8ede"
"oc"
end
language "om" do
sha256 "f1581ad9cf06156e15a8c06589d0aa19a1e7306ff74b87ab5a129a204b44f415"
"om"
end
language "or" do
sha256 "a212a56d7c21ef0d5f75f1202b5b8ff537fc9d21aec2de5b258c5eaedf08e435"
"or"
end
language "pa-IN" do
sha256 "381450a92e500fb563104ed9bfc3d3a4a622929f79777af8af598b7ab4dbb269"
"pa-IN"
end
language "pl" do
sha256 "f7f371f9555fc6a9b3fd9db3f288e243c39929a380a7ad2676a9c7a854de7b71"
"pl"
end
language "pt-BR" do
sha256 "9e4ec0dca65867d34106c075db409bd807bf005d700956e7c64773d2d1bb37a8"
"pt-BR"
end
language "pt" do
sha256 "a702f09ec68da5b3d44fa7360466b70b3fd27c9c40f5830e210f2e81c4e58e7b"
"pt"
end
language "ro" do
sha256 "a1ce96edca0c1903e99e417a053c6906c0c9911f6e64450d14f6fdae6fec5fd0"
"ro"
end
language "ru" do
sha256 "78f85663e7cffe1e256c87bcb3133c3214ae54959a7df2137a0071f95f047ce2"
"ru"
end
language "rw" do
sha256 "4c49cf5b2be8fcd58b65f19e3b70855dfe1d735f224a0ba331173efe9c03b55f"
"rw"
end
language "sa-IN" do
sha256 "7ebb73a7645ccad4783b5da2a82913e9c59207ba95042843ffe6e406a90e4a57"
"sa-IN"
end
language "sd" do
sha256 "c12dac0c20698a781484ca15c2498888d19761d5c8d6d4454d272b727f5043a4"
"sd"
end
language "si" do
sha256 "9f04f936e23cc5566acd477da5ec3720e3296d0e7ebf00ef7d5e47ccd643fb88"
"si"
end
language "sk" do
sha256 "327a53fd11fc0a789db9d5652122fc17599555d5167392aab1cf46b7586ec8b5"
"sk"
end
language "sl" do
sha256 "592d5053164ec2af491e56b91448813b735246270def6d76002f72016f1d5762"
"sl"
end
language "sq" do
sha256 "eb7b56eb2ec0886296515d2fa8c73cc580c882786c06fe583e32352a689d984f"
"sq"
end
language "sr" do
sha256 "fd2620b004af326b7eadad1c296676dbcc41e9cc56520388b9edaaac8e5f8981"
"sr"
end
language "ss" do
sha256 "7ae74ee503ff2593306c8efe47eb377b5069f69ef8fcbb765daa672c58301dcd"
"ss"
end
language "st" do
sha256 "6ad77b23b08d485ed6ab35284e6cbf9be244f9658277a1afed2ba505dc064d31"
"st"
end
language "sv" do
sha256 "772a69d687e16a4e8560150db27405e35b099190d7b09017951aa12a4c2e433e"
"sv"
end
language "sw-TZ" do
sha256 "41fae2dd59529c089a9d3e895ad6b42bb34da39f157a0e9892ce61dfab44c29c"
"sw-TZ"
end
language "ta" do
sha256 "d5eb73ac7469befa016009342f498eb682be2bbed0f1c1c7c3555710236d8cf4"
"ta"
end
language "te" do
sha256 "e61d1f1783b7126e7bc4fd591eaacb4ae9dcefd37e314478856de45f6f3a55f6"
"te"
end
language "tg" do
sha256 "12716465191afcc5383568d8573df62d92279f66e2d8e4fb9b445ccfc808137f"
"tg"
end
language "th" do
sha256 "6ed6415e9f49bce78c891c9bf90da38590fb540c428d13eaf6a1418abd2f898f"
"th"
end
language "tn" do
sha256 "70c22a63586937ecf4425e66f08546783bd106bd73056abcd3733dc602c8c25d"
"tn"
end
language "tr" do
sha256 "2b9e45a3add31a1f442450bc0702e57a2b04d7b84abc6bac94237145f278d2b5"
"tr"
end
language "ts" do
sha256 "8dcbfa48c207fae7787db97f8ea90f0da352a24689acbb59eabd980db83a4d6f"
"ts"
end
language "tt" do
sha256 "bb1e138c53c39c1e8960922e69010decb0adc6c4b14c86c550a25c8b6c90b1b3"
"tt"
end
language "ug" do
sha256 "4ac55fcb890d970057bb37305d437aac80ace396c060b0cc47f0f4e325c1c1e6"
"ug"
end
language "uk" do
sha256 "311aed0d9fa15c1fdc0982283b574e3920c1f4290f2ae9fa1409c2e4566fbf3e"
"uk"
end
language "uz" do
sha256 "73f2f5ef2353c65c3ebd33beb0321072a7261cca11b8b5e39bdf6bdc40deb1f1"
"uz"
end
language "ve" do
sha256 "d6d38172f8d6f15d794d8e00262843ee669339fdc529d05d4eab066d0509d619"
"ve"
end
language "vi" do
sha256 "905c072b6f1c24e0baf84ceaba528d4296c48ae36f08f06ad8298da9aec163a1"
"vi"
end
language "xh" do
sha256 "e0f27e96ee41430875ed9a2824b18f33518b0933f8e873707f244c7c1a61a90c"
"xh"
end
language "zh-CN" do
sha256 "87d16eae720d09866eeaef2e4d7ef484e4bc07340f8fac2a7812807cb0737b8b"
"zh-CN"
end
language "zh-TW" do
sha256 "038093665b07aeac258f8f1de489d57f641bf91c57a2f35e3e710335df6390bd"
"zh-TW"
end
language "zu" do
sha256 "2a7cc99d24e40b1f621b27cf9f55635d31d702f9c65c7a82e173f95343500d6e"
"zu"
end
else
language "af" do
sha256 "7b606105b03e422182617ced13c6ae7a7d6bfee8ab9a37f51a42787c879a4747"
"af"
end
language "am" do
sha256 "9c93a77e319e264618f75b8e0bae19b4e4b21d488d2b0b964377c912fbb25fa7"
"am"
end
language "ar" do
sha256 "118c5bef9f1532717900a597f6b64e2d51ef3e4ccaf02e6d3ad5d08c15c10a4d"
"ar"
end
language "as" do
sha256 "76ed1f13c84d55f2b9579663eddff4cc34e078502568b58216d529775df84da9"
"as"
end
language "be" do
sha256 "9fa13e3cabf658dba7c1da55bb99d2942530fdea3220d0ea9cf10139243d1ce0"
"be"
end
language "bg" do
sha256 "f111e494659d6df5f3dfd31f5334ef2870895009377fc34064ade0897abdb767"
"bg"
end
language "bn-IN" do
sha256 "be5320215832f506579e7e8c2ccb123aaeb704a265bf6f0ec4ea97be35387202"
"bn-IN"
end
language "bn" do
sha256 "67911f32a92e3bac177e94c005978525536cc84a449dfb78e0d0c779ffee1fea"
"bn"
end
language "bo" do
sha256 "dc2e5dbd89d0fda2b21361b520afe4d73156ce9dede10e82fb32e51dd818cd76"
"bo"
end
language "br" do
sha256 "d83c52a272eb972f118ec398175d64cc4137c44aadc4efe85dbaef26c578f2e0"
"br"
end
language "bs" do
sha256 "035c622ff7adfe29bfbbb3d0e51c81722c18266df9f9581efbd00632b5eed572"
"bs"
end
language "ca" do
sha256 "3d194afaa1ba8d9770f3d88f3e2c0e01135f1b545ae34ad4c85756176f18ff46"
"ca"
end
language "cs" do
sha256 "163dbde697416491783c505056f29a8cd60994c9359e185b7c28fba0a8c41d63"
"cs"
end
language "cy" do
sha256 "b4f42fefd8ea15f8bc920c8cdea17edc6734b4401b8f32512c041c8f62f0ed2d"
"cy"
end
language "da" do
sha256 "6329875d4a4e23385543fe5df6d0b3c2846b8b2d5dbf481647beb243e4d0af67"
"da"
end
language "de" do
sha256 "e7ae3f2bd6f03bcf789cb726a7104cf504230313bd93c3fc0e8e34e3f8d3eed2"
"de"
end
language "dz" do
sha256 "6fe2ff773f0018c3281926646c021ef5cdf01fb328e80679cad0b1bba9af5787"
"dz"
end
language "el" do
sha256 "745b7541e14831694772a7cb61e7d40b6f2b24568d686598794ad542c588eca5"
"el"
end
language "en-GB", default: true do
sha256 "f853d9fd01a2f057d838bc61b9a90d3f70c855518039ecaca89c6321fcc064b6"
"en-GB"
end
language "en-ZA" do
sha256 "72dab95cad59363dd5f54e78b7a04ae6825b123e764d6940ae2251d31f9a78f8"
"en-ZA"
end
language "eo" do
sha256 "eb9bc4abffc646668336d4cd68ef5f0611723f27e40898c7ef19376e47e77276"
"eo"
end
language "es" do
sha256 "8b4468130450cf0fed24d3fc501ff611a1624f2140ba1c7f23da9ce71cd82261"
"es"
end
language "et" do
sha256 "0ce798f2df48ab0c105de692ab7f5a09d9cd25e268d576499c2c2e25b8f1fcbc"
"et"
end
language "eu" do
sha256 "202b120ef8bf6f853570655dc6b91a4e5737bb81a5c9e256a9e04285d74d74ae"
"eu"
end
language "fa" do
sha256 "68174e0d2779b93cce6ce9b4438de74c7e602c2c1261164442078fc5a98db954"
"fa"
end
language "fi" do
sha256 "6dc2f14662ee4cc135f75e48ce70e182e9b767fbad2cc9fbb0dfb76735d05949"
"fi"
end
language "fr" do
sha256 "65658c9bfa1cc44044b9baefcf5ebad5b7067a4bf160757096685a4df0932427"
"fr"
end
language "fy" do
sha256 "acb63eec4704c382a095251bd7d0296d1dec4eb38a7251211d446e65b0e0d44a"
"fy"
end
language "ga" do
sha256 "1ca6c5d1a699367628146c07533b6305bbdaffc436e48d718b61a687b4e6662e"
"ga"
end
language "gd" do
sha256 "2318fab5ede7fba39e433870f59c006a01acabbebba03088c24f9031032935a5"
"gd"
end
language "gl" do
sha256 "7ec88634f670292cf06239e678fc713efa95b821da781da81741ab66d7a7dcbf"
"gl"
end
language "gu" do
sha256 "2f9ae9ca5c950c1d5861925bccdaf50e2ecd2776da8e78df9f0dc0b06f479bc2"
"gu"
end
language "he" do
sha256 "1885adc77fb6dbe1b19de8a8780db0ba94fc868c3737e4ccf935e73ded454e43"
"he"
end
language "hi" do
sha256 "80c98a8b806436200b39a507c3c401f87bab82baf0296049286fda293756f55c"
"hi"
end
language "hr" do
sha256 "3fdd3c7739c382894aeff89f39d7e60472607aa28862fc5afee1e0346189c921"
"hr"
end
language "hu" do
sha256 "b539a3ee8f7f79dab5da865c50e1ba4b892a7c8a7b22cc4f3f799b861d583f46"
"hu"
end
language "id" do
sha256 "562ac15b9515c4c761ee48f1342a43b785433be1f605e94584d306171a6b393e"
"id"
end
language "is" do
sha256 "45ec525f2ae18ebd691930d51675df3b7cbc358714843288f7101f59630214f8"
"is"
end
language "it" do
sha256 "79102949e642179b6e0684373c3e7b9f8a5fe5fe51796d6e808e312529349094"
"it"
end
language "ja" do
sha256 "b8455e4e06401905757eb520323e4e3ed07963d7a74085785f9f32a533f182a2"
"ja"
end
language "ka" do
sha256 "b0d2cf10d468fce94eb798ad69a4528aa9ac7f4c2ae179ad4581aa6e3b18fc10"
"ka"
end
language "kk" do
sha256 "32682e633f2052f73e04a25151cb24f8b73380ddf1c3ac1f851d83e89bb683f0"
"kk"
end
language "km" do
sha256 "7afec34b8fb7d26f0fdd3b328d6a793e3bec7742af1e4f0355a64691f0996d7f"
"km"
end
language "kn" do
sha256 "760396e2daf5bbab407b2385ad8abb59f576894e087b3889d96ead86230596b4"
"kn"
end
language "ko" do
sha256 "94dae9d2cd800a35db7a759e3605de0164e98dd39276a77287746671e88121de"
"ko"
end
language "ks" do
sha256 "c07bde8538762296ffaf83300322ada455f4e8b3fcd4679047759e773b1ffe81"
"ks"
end
language "lb" do
sha256 "061223ca522443ce0b5deb50b360dcc1910922eec7916bdcb7d01766c4a71bfc"
"lb"
end
language "lo" do
sha256 "2be39bbd48b8b11d5e7d2f67daf981e2133d0409e13606b75788745e96fce954"
"lo"
end
language "lt" do
sha256 "dc1f45a873569ea34f58fe56c94cfb67c18205239f5a3e5a30460aab876116bf"
"lt"
end
language "lv" do
sha256 "a19cb7f6cff87c88785f555561eac340115e859688c3500f1277a421716b6746"
"lv"
end
language "mk" do
sha256 "a0ed9f8e0e0527ee15f87f07efdc67fdd2f4e736e53b364737cc0f02369a1f34"
"mk"
end
language "ml" do
sha256 "dbbddac966b1a57c72a82e0b46f05532d408ad8d9b632f1898803a58dba6101e"
"ml"
end
language "mn" do
sha256 "d46873e9d6bc0a68fca53764858933a0d1d989680b35b0fa24e1a005f437e75d"
"mn"
end
language "mr" do
sha256 "659a6e17280cf36a090b6031699f06113aaefe6c5eff53a873890ae452409f08"
"mr"
end
language "my" do
sha256 "036cd1b936c152ae237f5403de81d5706c93976ffebdfd1518922c1c3f2d5db7"
"my"
end
language "nb" do
sha256 "b46cc26c541a0d8d061bf918fc4b4db033192a5a3bd628e5a74b40943f9dc405"
"nb"
end
language "ne" do
sha256 "e14c6357af0120214576f2991f88625372c4a68ff8ee6662131ed3a9e07be4eb"
"ne"
end
language "nl" do
sha256 "b3706c3fa8810c289ddb8ae3e5cc03b17573df960a55e0d39d14a6736686ecdf"
"nl"
end
language "nn" do
sha256 "e9f4f4bef9b6a6b12b32f6b1083dfb9cbf5b4a1e89fa4f9a65749ce7e4a33442"
"nn"
end
language "nr" do
sha256 "5b29711310d435b16cc461f7c529623e94e97140cf1a1c5172d02459f6c79d5c"
"nr"
end
language "oc" do
sha256 "8140580583cdb2ab58f211dae9bc51e2cc95a800daf9aece1045d89697bce0ec"
"oc"
end
language "om" do
sha256 "b4ddfa77c50ae446d6c1164f75e3e290b74b8796132ec69336cc3bdfe243010c"
"om"
end
language "or" do
sha256 "864e6ea55f57166f30b034ad8438837b9e5ed9e7dc68e346bd90b40e820533d6"
"or"
end
language "pa-IN" do
sha256 "49dadb68675a7178ea2fb8f257fef324a51acebddea6d331490c8e700d6506ef"
"pa-IN"
end
language "pl" do
sha256 "736548263e7a93a3d79b6f745c655b3c91249ff049b36b3b48a6cbe1b5c1d415"
"pl"
end
language "pt-BR" do
sha256 "27abe1b5b067bb769026f5aa0b355bd3bb51f07c69819ffc41ba72e00d63ec6e"
"pt-BR"
end
language "pt" do
sha256 "def14348ddf8dc044141b9f82d56048a32244c3bba06456c1ced11523542a6e0"
"pt"
end
language "ro" do
sha256 "02a5d42dbf492ed3bcefb4235d7bd51b842d43f137ced0c402695c43125d957d"
"ro"
end
language "ru" do
sha256 "a1cd43d033f051cf42ece1d1b7a92d7002ebeac5e4ab15a8ac180255cf292cc6"
"ru"
end
language "rw" do
sha256 "00cf34b9b5081b9bb93a1d652d201263ab89a61869de4162bd4101960c36ac35"
"rw"
end
language "sa-IN" do
sha256 "1898883d99fed4ae5f510634e524b4e323ab21b1de4bb11406640a0c7b7c4c5f"
"sa-IN"
end
language "sd" do
sha256 "74f4d0da3267701564a5e911fd5d6b893bf5611b2de5fb861926201c3ed8a6e7"
"sd"
end
language "si" do
sha256 "c7823e5224a4b3f83fa568262d31207e2df9a1bef7167e9ba6a22e227c43552c"
"si"
end
language "sk" do
sha256 "e3f70fb63b02838d4cb6d7a669cffc0589cfaf21ac4c1019ecb130a36818a7ab"
"sk"
end
language "sl" do
sha256 "14208ab0acb98cb8cc805bac7a8051221cfddd388a2a8b6c739f8f7026cfb8c9"
"sl"
end
language "sq" do
sha256 "e0d683d7d937cbdf21eb7160584de733b864f6e09e84519c2f14b58bbee06e87"
"sq"
end
language "sr" do
sha256 "e078240875d57c3027951e11badd5d799beff87042d1b019e2ac966878375222"
"sr"
end
language "ss" do
sha256 "28823e775422092dfdcb2664655b99a0456cb41dc2c4cd36351d8493536e2efd"
"ss"
end
language "st" do
sha256 "43e07a7daa9081e194e69e087ed06881443def8b7c3c49c1e92700d51e6a7624"
"st"
end
language "sv" do
sha256 "570e08efc364cd32f1d693d7698e0aee32a75905a5085b74ae0d2b8d563b9eef"
"sv"
end
language "sw-TZ" do
sha256 "e36b08dcaf9fe541ae18463689f4af1bd2314d227ecee005e1e1d25c25d7cf18"
"sw-TZ"
end
language "ta" do
sha256 "8343abd2565154692b0d3975d132a7a86680d28d4f1b2a4cd35a75cf2e229ba7"
"ta"
end
language "te" do
sha256 "13f4915701221f98293b91fcf811b44ddbdc5591bd5f7d7e27debe19261a7952"
"te"
end
language "tg" do
sha256 "f9600b59b9797003651a1fb1e5552333683758481f91e1e35ae7c107d62f4fd2"
"tg"
end
language "th" do
sha256 "bc328061b6c8999e74c76285dbb5e4f5a385bac91c022fe370f3bb7e0e1e9213"
"th"
end
language "tn" do
sha256 "4e48df1cf916f1cb0792ecf1e88271b53488426fad767725abbbeaade5678a85"
"tn"
end
language "tr" do
sha256 "7f76f4f8d0b982b507d48bb0600e4e34f655db00376fdfbb8ecb6b85dbdc0d5e"
"tr"
end
language "ts" do
sha256 "6423ee49fc1c8dc67bd7a0f305b30de15841ee255d1288a9aa23fe1303c0d0d8"
"ts"
end
language "tt" do
sha256 "6a9168c8d3b44128b8b1b528050f6f0ec22b598f0200563f9bcc7a573aed3620"
"tt"
end
language "ug" do
sha256 "71c4bb59708d485f585d694d06ee84cee17f08e4b0ea1a7af7e642cf8ba9424e"
"ug"
end
language "uk" do
sha256 "0e3f8b055e55319bf407e0589f537d9adb969d4d151468854276e061ef70be9b"
"uk"
end
language "uz" do
sha256 "ffaa139cb01a6edee39d851dcee218e2a5c16f10fbc5c6db83e564c6498af695"
"uz"
end
language "ve" do
sha256 "82c80a1a9ff0ce69fa53c0b78e93387a72e56755b259d2182331859f09cceb72"
"ve"
end
language "vi" do
sha256 "a3b70ab7c9325f02d8c35d6904df27626f307fcf8bdfe2f19c9d6513c4fecbed"
"vi"
end
language "xh" do
sha256 "497cb6b02894944b0d462cb11c86a5feb6f7d885bcee13bea4272523388efe9e"
"xh"
end
language "zh-CN" do
sha256 "686ba348bd4defe6b9b723df1e9a4b6a668adc0b84d14130238e809c47a7e8a5"
"zh-CN"
end
language "zh-TW" do
sha256 "51c7a90e2c4c50130cea86615131f16079f6dd1cb9e5564d02c32e1e6a0f3609"
"zh-TW"
end
language "zu" do
sha256 "f3be827d60fe08a60d2fd86a235afc56ddacdc6eb790608205dc2759e51cb09e"
"zu"
end
end
url "https://download.documentfoundation.org/libreoffice/stable/#{version}/mac/#{folder}/LibreOffice_#{version}_MacOS_#{arch}_langpack_#{language}.dmg",
verified: "download.documentfoundation.org/libreoffice/stable/"
name "LibreOffice Language Pack"
desc "Collection of alternate languages for LibreOffice"
homepage "https://www.libreoffice.org/"
livecheck do
url "https://download.documentfoundation.org/libreoffice/stable/"
strategy :page_match
regex(%r{href="(\d+(?:\.\d+)*)/"}i)
end
depends_on cask: "libreoffice"
depends_on macos: ">= :yosemite"
installer manual: "LibreOffice Language Pack.app"
# Not actually necessary, since it would be deleted anyway.
# It is present to make clear an uninstall was not forgotten
# and that for this cask it is indeed this simple.
# See https://github.com/Homebrew/homebrew-cask/pull/52893
uninstall delete: "#{staged_path}/#{token}"
end
|
omhmichaels/homebrew-cask
|
Casks/lulu.rb
|
cask "lulu" do
version "2.4.0"
sha256 "114d73ef5395e3a26919623235e7f22347fe0ab83265c93ff5b5d1bcebc42ee2"
url "https://github.com/objective-see/LuLu/releases/download/v#{version}/LuLu_#{version}.dmg",
verified: "github.com/objective-see/LuLu/"
name "LuLu"
desc "Open-source firewall to block unknown outgoing connections"
homepage "https://objective-see.com/products/lulu.html"
livecheck do
url :url
strategy :github_latest
end
auto_updates true
depends_on macos: ">= :catalina"
app "LuLu.app"
uninstall script: {
executable: "#{appdir}/LuLu.app/Contents/Resources/LuLu Uninstaller.app/Contents/MacOS/LuLu Uninstaller",
args: ["-uninstall"],
sudo: true,
}
zap trash: [
"~/Library/Caches/com.objective-see.lulu",
"~/Library/Caches/com.objective-see.lulu.helper",
"~/Library/Preferences/com.objective-see.lulu.plist",
"~/Library/Preferences/com.objective-see.lulu.helper.plist",
]
end
|
omhmichaels/homebrew-cask
|
Casks/lunar-client.rb
|
<reponame>omhmichaels/homebrew-cask
cask "lunar-client" do
version "2.8.4"
sha256 "c7031f10a242f15dbccdbdd69866098fd7776777feba033bfb2faacf331cf9f6"
url "https://launcherupdates.lunarclientcdn.com/Lunar%20Client%20v#{version}.dmg",
verified: "launcherupdates.lunarclientcdn.com/"
name "Lunar Client"
desc "Modpack for Minecraft 1.7.10 and 1.8.9"
homepage "https://www.lunarclient.com/"
livecheck do
url "https://launcherupdates.lunarclientcdn.com/latest-mac.yml"
strategy :electron_builder
end
auto_updates true
depends_on macos: ">= :el_capitan"
app "Lunar Client.app"
zap trash: [
"~/Library/Application Support/lunarclient",
"~/Library/Caches/com.moonsworth.client",
"~/Library/Caches/com.moonsworth.client.ShipIt",
"~/Library/Logs/Lunar Client",
"~/Library/Preferences/com.moonsworth.client.plist",
"~/Library/Saved Application State/com.moonsworth.client.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/spitfire-audio.rb
|
cask "spitfire-audio" do
version "3.3.17,1634741700"
sha256 "52cc1e28b23804ab92c78862cf51bb732e2c90e19ca555bfc628aeab8cfbff99"
url "https://d1t3zg51rvnesz.cloudfront.net/p/files/lm/#{version.after_comma}/mac/SpitfireAudio-Mac-#{version.before_comma}.dmg",
verified: "d1t3zg51rvnesz.cloudfront.net/"
name "Spitfire Audio"
desc "Download manager for Spitfire audio libraries"
homepage "https://www.spitfireaudio.com/info/library-manager/"
livecheck do
url "https://www.spitfireaudio.com/library-manager/download/mac/"
strategy :header_match do |headers|
match = headers["location"].match(%r{/(\d+)/.*-(\d+(?:\.\d+)*)\.dmg}i)
next if match.blank?
"#{match[2]},#{match[1]}"
end
end
auto_updates true
app "Spitfire Audio.app"
uninstall delete: [
"/Library/LaunchDaemons/com.spitfireaudio.LibraryManagerHelper.plist",
"/Library/Logs/Spitfire Audio",
"/Library/PrivilegedHelperTools/com.spitfireaudio.LibraryManagerHelper",
]
zap delete: [
"~/Library/Caches/com.spitfireaudio.spitfireaudio",
"~/Library/Preferences/com.spitfireaudio.spitfireaudio.plist",
]
end
|
omhmichaels/homebrew-cask
|
Casks/loom.rb
|
<gh_stars>100-1000
cask "loom" do
arch = Hardware::CPU.intel? ? "" : "-arm64"
version "0.102.0"
url "https://cdn.loom.com/desktop-packages/Loom-#{version}#{arch}.dmg"
if Hardware::CPU.intel?
sha256 "141d4740c91ea4c4809d9fd0f749c23e8841cf979b59d6fdc6499925189c8323"
else
sha256 "e1249d8816ac68a619d1d524f8d4e790326e83735fbd61e5ddf89570a17b85ee"
end
name "Loom"
desc "Screen and video recording software"
homepage "https://www.loom.com/"
livecheck do
url "https://s3-us-west-2.amazonaws.com/loom.desktop.packages/loom-inc-production/desktop-packages/latest-mac.yml"
strategy :electron_builder
end
auto_updates true
app "Loom.app"
end
|
omhmichaels/homebrew-cask
|
Casks/bluej.rb
|
<filename>Casks/bluej.rb
cask "bluej" do
version "5.0.2"
sha256 "e9073a0779698ef2214ce2c7308dd4d3a89878e975e2a9ea23fc04820c5afddf"
url "https://www.bluej.org/download/files/BlueJ-mac-#{version.no_dots}.zip"
name "BlueJ"
desc "Java Development Environment designed for begginers"
homepage "https://www.bluej.org/"
livecheck do
url "https://www.bluej.org"
strategy :page_match do |page|
match = page.match(%r{href=.*?/BlueJ-mac-(\d+)(\d+)(\d+)\.zip}i)
"#{match[1]}.#{match[2]}.#{match[3]}"
end
end
app "BlueJ #{version}/BlueJ.app"
zap trash: "~/Library/Preferences/org.bluej"
end
|
omhmichaels/homebrew-cask
|
Casks/geany.rb
|
cask "geany" do
version "1.38"
sha256 "8467c87377672e271dab0144cb96f0c4b46b48ce6d5df5223bb39b5a32350f84"
url "https://download.geany.org/geany-#{version}_osx.dmg"
name "Geany"
desc "Fast and lightweight IDE"
homepage "https://www.geany.org/"
livecheck do
url "https://geany.org/download/releases/"
strategy :page_match do |page|
match = page.match(/href=.*?geany[._-](\d+(?:\.\d+)+)[._-]osx(?:[._-](\d+))?\.dmg/i)
match[2] ? "#{match[1]},#{match[2]}" : match[1]
end
end
app "Geany.app"
end
|
omhmichaels/homebrew-cask
|
Casks/cloudash.rb
|
cask "cloudash" do
version "1.2.1"
sha256 "9b536fdd002bf05b907e8e13c7df9f2fe13ed5fc1dfeebb638fb3f1142fec103"
url "https://github.com/cloudashdev/cloudash/releases/download/#{version}/Cloudash-#{version}.dmg",
verified: "github.com/cloudashdev/cloudash/"
name "cloudash"
desc "Monitoring and troubleshooting for serverless architectures"
homepage "https://cloudash.dev/"
app "Cloudash.app"
zap trash: [
"~/Library/Application Support/cloudash",
"~/Library/Logs/Cloudash",
"~/Library/Preferences/dev.cloudash.cloudash.plist",
"~/Library/Saved Application State/dev.cloudash.cloudash.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/ogdesign-eagle.rb
|
cask "ogdesign-eagle" do
arch = Hardware::CPU.intel? ? "build" : "M1-build"
version "2.0,37"
url "https://eagleapp.s3-accelerate.amazonaws.com/releases/Eagle-#{version.before_comma}-#{arch}#{version.after_comma}.dmg",
verified: "eagleapp.s3-accelerate.amazonaws.com/"
if Hardware::CPU.intel?
sha256 "de2035bb67ed397e278f8accd841f3a0ae9f6a5d802d1a9f6a7536a999beca26"
else
sha256 "bc6315aa3092412ecad2093fbffa5e6fad7ccb37cb1f556725c04e236a015773"
end
name "Eagle"
desc "Organize all your reference images in one place"
homepage "https://eagle.cool/macOS"
livecheck do
url "https://eagle.cool/check-for-update"
regex(/Eagle[._-]v?(\d+(?:\.\d+)+)-#{arch}(\d+(?:\.\d+)*)\.dmg/i)
strategy :page_match do |page, regex|
match = page.match(regex)
next if match.blank?
"#{match[1]},#{match[2]}"
end
end
app "Eagle.app"
end
|
omhmichaels/homebrew-cask
|
Casks/openttd.rb
|
<reponame>omhmichaels/homebrew-cask<filename>Casks/openttd.rb
cask "openttd" do
version "12.0"
sha256 "67466d41afe806db5ffa7d9115d4c633713075d0cd839d3b419e285efea42ac0"
url "https://proxy.binaries.openttd.org/openttd-releases/#{version}/openttd-#{version}-macos-universal.zip"
name "OpenTTD"
desc "Open-source transport simulation game"
homepage "https://www.openttd.org/"
livecheck do
url "https://www.openttd.org/downloads/openttd-releases/latest.html"
strategy :page_match
regex(%r{href=.*?/openttd-(\d+(?:\.\d+)*)-macos-universal\.zip}i)
end
app "OpenTTD.app"
zap trash: [
"~/Documents/OpenTTD",
"~/Library/Application Support/CrashReporter/openttd_*.plist",
"~/Library/Logs/DiagnosticReports/openttd_*.crash",
"~/Library/Saved Application State/org.openttd.openttd.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/vitalsource-bookshelf.rb
|
<filename>Casks/vitalsource-bookshelf.rb
cask "vitalsource-bookshelf" do
version "10.0.1.1366"
sha256 "0937eb27cc7d1120502d22a6949080f6a886a07e77c57fda0d18d1717bcd44a2"
url "https://downloads.vitalbook.com/vsti/bookshelf/#{version.major_minor_patch}/mac/bookshelf/VitalSource-Bookshelf_#{version}.dmg",
verified: "downloads.vitalbook.com/vsti/bookshelf"
name "VitalSource Bookshelf"
desc "Access eTextbooks"
homepage "https://www.vitalsource.com/bookshelf-features"
livecheck do
url "https://support.vitalsource.com/api/v2/help_center/en-us/articles/360014107913"
regex(/href=.*?VitalSource-Bookshelf[._-]v?(\d+(?:\.\d+)+)\.dmg/i)
end
depends_on macos: ">= :high_sierra"
app "VitalSource Bookshelf.app"
zap trash: [
"~/Library/Application Support/com.vitalsource.bookshelf",
"~/Library/Logs/Vitalsource Bookshelf",
"~/Library/Preferences/com.vitalsource.bookshelf.plist",
]
end
|
omhmichaels/homebrew-cask
|
Casks/datweatherdoe.rb
|
cask "datweatherdoe" do
version "2.1.4"
sha256 "1f336467f6ea85e0be250d55ed9086ae0c2d1e9022accabc82a2451a9df726ef"
url "https://github.com/inderdhir/DatWeatherDoe/releases/download/#{version}/DatWeatherDoe-#{version}.dmg"
name "DatWeatherDoe"
desc "Menu bar weather app"
homepage "https://github.com/inderdhir/DatWeatherDoe"
livecheck do
url :url
strategy :github_latest
end
app "DatWeatherDoe.app"
zap trash: "~/Library/Preferences/com.inderdhir.DatWeatherDoe.plist"
end
|
omhmichaels/homebrew-cask
|
Casks/plexamp.rb
|
<reponame>omhmichaels/homebrew-cask<filename>Casks/plexamp.rb
cask "plexamp" do
if Hardware::CPU.intel?
version "3.7.1"
sha256 "2c906f70564c01cfd10b10f7433e31d4f6637c57416860c39d0f84a1264f77b3"
url "https://plexamp.plex.tv/plexamp.plex.tv/desktop/Plexamp-#{version}.dmg",
verified: "plexamp.plex.tv/"
livecheck do
url "https://plexamp.plex.tv/plexamp.plex.tv/desktop/latest-mac.yml"
strategy :electron_builder
end
else
version "3.5.0"
sha256 "ead85dd518814718ce57b47a2cf76d0f290a9fd6465c88369d33964a67dbb76d"
url "https://plexamp.plex.tv/plexamp.plex.tv/desktop/Plexamp-#{version}-arm64.dmg",
verified: "plexamp.plex.tv/"
livecheck do
skip "No version information available"
end
end
name "Plexamp"
desc "Music player focusing on visuals"
homepage "https://plexamp.com/"
app "Plexamp.app"
end
|
omhmichaels/homebrew-cask
|
Casks/tabby.rb
|
<gh_stars>100-1000
cask "tabby" do
arch = Hardware::CPU.intel? ? "x86_64" : "arm64"
version "1.0.159"
url "https://github.com/Eugeny/tabby/releases/download/v#{version}/tabby-#{version}-macos-#{arch}.zip",
verified: "github.com/Eugeny/tabby/"
if Hardware::CPU.intel?
sha256 "1fc3e8e9297e9c8ba6481e66947bc4f17902ed4ddc090ccbb20f2dc385e3f155"
else
sha256 "0f3e85e6f236216d8ac1d5e3f4dcd680cb18264da04d3235d885359e1068d4eb"
end
name "Tabby"
name "Terminus"
desc "Terminal emulator, SSH and serial client"
homepage "https://eugeny.github.io/tabby/"
livecheck do
url :url
strategy :github_latest
end
app "Tabby.app"
zap trash: [
"~/Library/Application Support/tabby",
"~/Library/Preferences/org.tabby.helper.plist",
"~/Library/Preferences/org.tabby.plist",
"~/Library/Saved Application State/org.tabby.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/chirp.rb
|
cask "chirp" do
version "20211016"
sha256 "a4c4ebaa11334e757ca24070b565ed9874c22cc73ac67e6a856559d8eec744ab"
url "https://trac.chirp.danplanet.com/chirp_daily/daily-#{version}/chirp-unified-daily-#{version}.app.zip"
name "CHIRP"
desc "Tool for programming amateur radio"
homepage "https://chirp.danplanet.com/projects/chirp/wiki/Home"
livecheck do
url "https://trac.chirp.danplanet.com/chirp_daily/LATEST/SHA1SUM"
regex(/chirp[._-]unified[._-]daily[._-]v?(\d+(?:\.\d+)*)\.app\.zip/i)
end
app "CHIRP.app"
end
|
omhmichaels/homebrew-cask
|
Casks/archi.rb
|
cask "archi" do
arch = Hardware::CPU.intel? ? "" : "-Silicon"
version "4.9.0"
if Hardware::CPU.intel?
sha256 "72d90bdd79762ccdf2daf463d6ea950a863df33cde5e1e5ae054ee8ee5e43d04"
else
sha256 "317a72129385f80829d1cb20d21a5fed76764afeb26f1eb4fc2f6e566f80b56d"
end
url "https://www.archimatetool.com/downloads/archi/?d1=#{version}/Archi-Mac#{arch}-#{version}.dmg",
using: :post
name "Archi"
name "ArchiMate Tool"
desc "Modelling toolkit for ArchiMate models and sketches"
homepage "https://www.archimatetool.com/"
livecheck do
url "https://www.archimatetool.com/download/"
regex(/\s+id\s*=\s*"download"\s+data-version\s*=\s*"(\d+(?:\.\d+)+)"/i)
end
depends_on macos: ">= :sierra"
app "Archi.app"
zap trash: [
"~/Library/Application Support/Archi*",
"~/Library/Caches/com.archimatetool.editor",
"~/Library/Preferences/com.archimatetool.editor.plist",
"~/Library/Saved Application State/com.archimatetool.editor.savedState",
]
end
|
omhmichaels/homebrew-cask
|
Casks/the-clock.rb
|
<reponame>omhmichaels/homebrew-cask
cask "the-clock" do
version "4.5.1,20210115"
sha256 :no_check
url "https://seense.com/the_clock/updateapp/the_clock.zip"
name "The Clock"
desc "Clock and time zone app"
homepage "https://seense.com/the_clock/"
livecheck do
url "https://www.seense.com/the_clock/updateapp/appcast.xml"
strategy :sparkle
end
auto_updates true
depends_on macos: ">= :sierra"
app "The Clock.app"
uninstall quit: "com.fabriceleyne.theclock"
zap trash: [
"~/Library/Application Scripts/com.fabriceleyne.theclock",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcCalendarWidget",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcCalendarWidgetIntent",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcClassicClockWidget",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcClassicClockWidgetIntent",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcClockWidget",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcClockWidgetIntent",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcMiniClockWidget",
"~/Library/Application Scripts/com.fabriceleyne.theclock.tcMiniClockWidgetIntent",
"~/Library/Containers/com.fabriceleyne.theclock",
"~/Library/Containers/com.fabriceleyne.theclock.tcCalendarWidget",
"~/Library/Containers/com.fabriceleyne.theclock.tcCalendarWidgetIntent",
"~/Library/Containers/com.fabriceleyne.theclock.tcClassicClockWidget",
"~/Library/Containers/com.fabriceleyne.theclock.tcClassicClockWidgetIntent",
"~/Library/Containers/com.fabriceleyne.theclock.tcClockWidget",
"~/Library/Containers/com.fabriceleyne.theclock.tcClockWidgetIntent",
"~/Library/Containers/com.fabriceleyne.theclock.tcMiniClockWidget",
"~/Library/Containers/com.fabriceleyne.theclock.tcMiniClockWidgetIntent",
"~/Library/Group Containers/3EYN7PPTPF.com.fabriceleyne.theclock",
]
end
|
mallowlabs/ruboty-redash
|
lib/ruboty/redash/client.rb
|
<reponame>mallowlabs/ruboty-redash
# frozen_string_literal: true
require 'faraday'
require 'json'
module Ruboty
module Redash
class Client
def initialize(root, user_apikey)
@root = root
@user_apikey = user_apikey
@client = build
end
def fetch(query_id)
result_id = latest_query_data_id(query_id)
query_result_data(result_id)
end
private
def query_result_data(result_id)
json = query_result(result_id)
json['query_result']['data']
end
def query_result(result_id)
res = client.get("/api/query_results/#{result_id}")
parse_json(res)
end
def latest_query_data_id(query_id)
json = query(query_id)
json['latest_query_data_id']
end
def query(query_id)
res = client.get("/api/queries/#{query_id}")
parse_json(res)
end
def parse_json(response)
unless response.success?
warn response.body
throw 'fetch error'
end
JSON.parse(response.body)
end
def build
Faraday.new(url: root) do |builder|
builder.authorization('Key', user_apikey) if user_apikey
builder.adapter Faraday.default_adapter
end
end
attr_reader :root, :user_apikey, :client
end
end
end
|
mallowlabs/ruboty-redash
|
spec/ruboty/handlers/redash_spec.rb
|
# frozen_string_literal: true
RSpec.describe Ruboty::Handlers::Redash do
let(:action) { double(:action) }
let(:robot) { Ruboty::Robot.new }
describe '#show' do
it 'call action' do
expect(Ruboty::Redash::Actions::Show).to receive(:new).and_return(action)
expect(action).to receive(:call)
robot.receive(body: "ruboty redash show 9 Today's KPI is <%= data['rows'][-1]['kpi'] =>")
end
end
end
|
mallowlabs/ruboty-redash
|
lib/ruboty/handlers/redash.rb
|
# frozen_string_literal: true
require 'ruboty'
module Ruboty
module Handlers
class Redash < Base
on(/redash show (?<query_id>\d+)(?<format> .*)?\z/, name: 'show', description: 'get data from Redash')
def show(message)
Ruboty::Redash::Actions::Show.new(message).call
end
end
end
end
|
mallowlabs/ruboty-redash
|
lib/ruboty/redash.rb
|
# frozen_string_literal: true
require "ruboty/redash/version"
require "ruboty/redash/client"
require "ruboty/redash/actions/show"
require "ruboty/handlers/redash"
|
mallowlabs/ruboty-redash
|
lib/ruboty/redash/actions/show.rb
|
# frozen_string_literal: true
require 'erb'
module Ruboty
module Redash
module Actions
class Show
def initialize(message)
@message = message
end
def call
throw 'config error: set REDASH_ROOT' unless redash_root
data = Ruboty::Redash::Client.new(redash_root, redash_user_apikey).fetch(query_id)
message.reply(reply_message(binding))
rescue => e
warn "#{e.message}\n#{e.backtrace.join("\n")}"
message.reply(e.message)
end
private
def reply_message(b = binding)
ERB.new(format).result(b)
end
def format
message[:format] || "<%= data %>"
end
def query_id
message[:query_id]
end
def redash_user_apikey
ENV['REDASH_USER_APIKEY']
end
def redash_root
ENV['REDASH_ROOT']
end
attr_reader :message
end
end
end
end
|
mallowlabs/ruboty-redash
|
spec/ruboty/redash_spec.rb
|
<filename>spec/ruboty/redash_spec.rb
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Ruboty::Redash do
it "has a version number" do
expect(Ruboty::Redash::VERSION).not_to be nil
end
end
|
hwesselmann/ranking-info
|
config/routes.rb
|
Rails.application.routes.draw do
root 'static_pages#home'
get '/help', to: 'static_pages#help'
get '/about', to: 'static_pages#about'
get '/privacy', to: 'static_pages#privacy'
get '/status', to: 'import#info'
get '/import', to: 'import#upload'
post '/import', to: 'import#import'
get '/players', to: 'players#index'
get '/player/:id', to: 'players#show', as: :player
get '/listings', to: 'listing#index'
get '/clubs', to: 'clubs#index'
get '/club/:id', to: 'clubs#show', as: :club, constraints: { id: /.+/ }
get '/federations', to: 'federations#index'
get '/login', to: 'sessions#new'
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
resources :import do
collection { post :import }
end
end
|
hwesselmann/ranking-info
|
app/controllers/listing_controller.rb
|
# frozen_string_literal: true
#
# Controller covering all actions concerning the ranking list.
#
class ListingController < ApplicationController
def index
@quarters = fetch_available_quarters
@federations = federations
return unless params[:commit]
# we have a filter request - let's evaluate the params
# 1. quarter => required
query = "date='#{params[:quarter]}'"
# 2. gender => required
query += gender_selected(params[:gender])
# 3. age group => a value will be used in the query in any case
query += age_group_selected(params[:age_group])
# 4. age group options?
query += age_group_options(params[:age_group][1, 2].to_i,
params[:age_group_options])
# 5. federation
query += federation_selected(params[:federation])
# 6. club
query += club_selected(params[:club])
# 7. year end ranking
# if year end lists should be shown and the quarter selected is a Q4...
query += year_end_rankings(params[:year_end], params[:quarter])
# run the query!
@rankings = Ranking.where(query).order(:ranking_position, score: :desc)
end
private
def fetch_available_quarters
available_rankings = Ranking.select(:date).order(date: :desc).distinct
years = available_years(available_rankings)
quarters = {}
years.each do |y|
quarters[y] = available_quarters_for_year(y, available_rankings)
end
quarters
end
def available_years(rankings)
years = []
rankings.each do |r|
years.push((r.date - 1.day).year.to_s) unless r.date.month.eql?(12)
end
years
end
def available_quarters_for_year(year, rankings)
quarters = []
rankings.each do |r|
next unless year.eql?((r.date - 1.day).year.to_s)
# do not show year end ranking dates - they are triggered via checkbox
unless r.date.month.eql?(12) && r.date.day.eql?(31)
quarters.push([(r.date - 1.day).strftime('%d.%m.%Y'),
r.date.strftime('%Y-%m-%d')])
end
end
quarters
end
def federations
federations = []
rankings = Ranking.select(:federation).order(:federation).distinct
rankings.each do |ranking|
federations.push ranking.federation
end
federations
end
def gender_selected(gender)
if gender.eql?('Junioren')
then ' AND (dtb_id >= 10000000 AND dtb_id <= 19999999)'
else ' AND (dtb_id >= 20000000 AND dtb_id <= 29999999)'
end
end
def age_group_selected(age_group)
if age_group.eql?('') then " AND age_group='overall'"
else " AND age_group='#{params[:age_group]}'"
end
end
def age_group_options(age_group, age_group_options)
if age_group_options.eql?('') && age_group.even?
then ' AND yob_ranking=false AND age_group_ranking=true'
elsif age_group_options.eql?('') && age_group.odd?
then ' AND yob_ranking=true AND age_group_ranking=false'
elsif age_group_options.eql?('only_yob')
then ' AND yob_ranking=true AND age_group_ranking=false'
elsif age_group_options.eql?('include_younger')
then ' AND yob_ranking=false AND age_group_ranking=false'
end
end
def federation_selected(federation)
if federation.eql?('') then ''
else " AND federation='#{federation}'"
end
end
def club_selected(club)
if club.eql?('') then ''
else " AND LOWER(club) LIKE LOWER('%#{club}%')"
end
end
def year_end_rankings(year_end, quarter)
if year_end.eql?('1') && first_quarter?(quarter)
then ' AND year_end_ranking=true'
else ' AND year_end_ranking=false'
end
end
def first_quarter?(quarter)
quarter.split('-')[1].eql?('01')
end
end
|
hwesselmann/ranking-info
|
app/controllers/application_controller.rb
|
# frozen_string_literal: true
#
# Rails application controller.
#
class ApplicationController < ActionController::Base
include SessionsHelper
end
|
hwesselmann/ranking-info
|
test/controllers/listing_controller_test.rb
|
require 'test_helper'
class ListingControllerTest < ActionDispatch::IntegrationTest
test 'should get listings' do
get listings_path
assert_response :success
assert_select 'title', full_title('Ranglisten')
end
end
|
hwesselmann/ranking-info
|
app/helpers/application_helper.rb
|
# frozen_string_literal: true
#
# Rails application helper.
#
module ApplicationHelper
# Returns the full title on a per-page basis.
def full_title(page_title = '')
base_title = 'Ranking-Info'
if page_title.empty?
base_title
else
"#{page_title} | #{base_title}"
end
end
# fetch available quarters generally or for a player if dtb_id is given
def fetch_available_quarters(dtb_id: '')
available_rankings = load_rankings(dtb_id)
year = 0
years = {}
quarters = []
available_rankings.each do |ar|
unless ar.date.year.eql?(year)
# new year, shift
unless year.eql?(0)
years[year.to_s] = quarters.reverse
quarters.clear
end
year = ar.date.year
end
quarters.push ar.date.strftime('%d.%m.')
end
years[year.to_s] = quarters.reverse
years
end
def load_rankings(dtb_id)
if dtb_id.eql?('')
then Ranking.select(:date).order(date: :desc).distinct
else Ranking.select(:date)
.where(dtb_id: dtb_id)
.order(date: :desc)
.distinct
end
end
def federation_long_name(short)
fed = { BAD: 'Baden', BB: 'Berlin-Brandenburg', BTV: 'Bayern', HAM: 'Hamburg',
HTV: 'Hessen', RPF: 'Rheinland-Pfalz', SLH: 'Schleswig-Holstein',
STB: 'Saarland', STV: 'Sachsen', TMV: 'Mecklenburg-Vorpommern',
TNB: 'Niedersachsen-Bremen', TSA: 'Sachsen-Anhalt', TTV: 'Thüringen',
TVM: 'Mittelrhein', TVN: 'Niederrhein', WTB: 'Würtemberg', WTV: 'Westfalen' }
fed[short.to_sym] || short
end
end
|
hwesselmann/ranking-info
|
app/models/ranking.rb
|
# frozen_string_literal: true
require 'csv'
#
# a model for a ranking - the main item of this software
# this model includes some class methods to import new rankings
#
class Ranking < ApplicationRecord
def self.import_rankings(file)
period_to_import = extract_period_from_filename(file)
store_rankings_from_csv(file, period_to_import)
gender_factor = extract_gender_from_filename(file)
calculate_rankings(period_to_import, gender_factor)
end
#
# Extract the period the import file is for from the filename.
#
# @param [String] filename filename to extract period from
#
# @return [Date] Ruby Date object containing the extracted period
#
def self.extract_period_from_filename(filename)
logger.debug "extracting period part from file '#{filename}'"
filename_without_path = filename.split('/').last
filename_without_extension = filename_without_path.split('.').first
filename_parts = filename_without_extension.split('_')
if filename_parts.size >= 2
create_time_from_string(filename_parts)
else
logger.error "could not retrieve period part from filename '#{filename}'"
raise "could not retrieve period part from filename '#{filename}'"
end
end
#
# Use an input string in foramt 'yyyymmdd' to create a Time object
#
# @param [String] input date as String 'yyyymmdd'
#
# @return [Time] Ruby time object corresponding to the input
#
def self.create_time_from_string(input)
year = input.last[0, 4]
month = input.last[4, 2]
day = input.last[6, 2]
logger.debug "construction new Time object with '#{year}-#{month}-#{day}'"
Time.new(year, month, day)
end
#
# Save ranking entries for a period into the dabatase.
#
# @param [String] name of the file to import from
# @param [Time] period_to_import period for the current data import
#
def self.store_rankings_from_csv(file, period_to_import)
input = CSV.read(file, encoding: 'utf-8')
input.each do |entry|
save_ranking(entry, period_to_import)
end
end
def self.save_ranking(entry, period_to_import)
Ranking.create(dtb_id: entry[4].split(' ').first.to_i,
age_group: 'overall',
date: period_to_import,
ranking_position: entry[0].to_i,
lastname: entry[1],
firstname: entry[2],
nationality: entry[3],
score: entry[6],
age_group_ranking: false,
yob_ranking: false,
year_end_ranking: false,
club: entry[5],
federation: entry[4].split(' ').last)
end
#
# Caculate ranking for this period for all age groups and save to datastore.
#
# @param [Time] period_to_import period to calculate a full set of rankings
#
def self.calculate_rankings(period, gender)
yob_youngest_age_group = period.year - 11
logger.info "under 11 age group for current calculation
has birth year #{yob_youngest_age_group}"
birth_year_four_digits = yob_youngest_age_group.to_s
# 1. general rankings for all age groups
[11, 12, 13, 14, 15, 16, 17, 18].each do |age_group|
logger.debug "calculating general rankings for U#{age_group}"
yobs_to_fetch = yob_range_to_fetch(birth_year_four_digits,
age_group, period, gender)
rankings_for_age_range_in_period(yobs_to_fetch.sort, period, age_group,
false, false, false)
end
# 2. yob rankings
[11, 12, 13, 14, 15, 16, 17, 18].each do |age_group|
logger.debug "calculating yob rankings U#{age_group}"
yobs_to_fetch = [(period.year - age_group).to_s[2, 4].to_i + gender]
rankings_for_age_range_in_period(yobs_to_fetch.sort, period, age_group,
true, false, false)
end
# 3. age group rankings
[12, 14, 16, 18].each do |age_group|
logger.debug "calculating age group rankings U#{age_group}"
yobs_to_fetch = [(period.year - age_group).to_s[2, 4].to_i + gender,
(period.year - age_group).to_s[2, 4].to_i + gender + 1]
rankings_for_age_range_in_period(yobs_to_fetch.sort, period, age_group,
false, true, false)
end
# 4. in case we are importing the last quarter -
# final listings for official age groups
return unless period.month.eql?(1)
# this is the final update for this year!
ye_date = period - 1.day
[12, 14, 16, 18].each do |age_group|
logger.debug "calculating year final age group rankings U#{age_group}"
yobs_to_fetch = [(ye_date.year - age_group).to_s[2, 4].to_i + gender,
(ye_date.year - age_group).to_s[2, 4].to_i + gender + 1]
rankings_for_age_range_in_period(yobs_to_fetch.sort, period, age_group,
false, true, true)
end
end
#
# Get a range of years of birth to retrieve for ranking calculation.
#
# @param [String] yob
# @param [Integer] age_group to fetch
# @param [Time] period to calculate
# @param [Integer] gender factor for dtb-id prefix
#
# @return [Array] array containing range to fetch for calculation of rankings
#
def self.yob_range_to_fetch(yob, age_group, period, gender_factor)
classes_of_players_to_retrieve = []
yob_gender_marker = yob[2, 4].to_i + gender_factor
i = 0
while age_group >= period.year - yob.to_i + i
classes_of_players_to_retrieve.push(yob_gender_marker - i)
i += 1
end
classes_of_players_to_retrieve
end
def self.rankings_for_age_range_in_period(classes_to_retrieve, period, age_group, is_yob_ranking, is_age_group_ranking, year_end_ranking)
id_start = classes_to_retrieve.first * 100_000
id_end = classes_to_retrieve.last * 100_000 + 99_999
rankings_from_db = load_ranking_for_age_range(id_start, id_end, period)
last_rank = 0
start_ranking = 0
count_up = 1
rankings_from_db.each do |curr_ranking|
ranking = Ranking.new
if curr_ranking.ranking_position > last_rank
last_rank = curr_ranking.ranking_position
start_ranking = count_up
end
ranking.age_group = "U#{age_group}"
ranking.date = curr_ranking.date
ranking.yob_ranking = is_yob_ranking
ranking.age_group_ranking = is_age_group_ranking
ranking.year_end_ranking = year_end_ranking
ranking.ranking_position = start_ranking
ranking.dtb_id = curr_ranking.dtb_id
ranking.lastname = curr_ranking.lastname
ranking.firstname = curr_ranking.firstname
ranking.nationality = curr_ranking.nationality
ranking.club = curr_ranking.club
ranking.federation = curr_ranking.federation
ranking.score = curr_ranking.score
# ranking is only counted up for German players,
# foreign player get the right position, but are not adding
# up to the actual position, also players with pr or Einstufung do not count
if curr_ranking.nationality.eql?('GER') && !curr_ranking.score.eql?('0,0') &&
!curr_ranking.score.eql?('PR') && !curr_ranking.score.eql?('Einst.')
count_up += 1
end
ranking.save
end
end
def self.load_ranking_for_age_range(dtb_id_start, dtb_id_end, period)
Ranking.where(date: period,
dtb_id: dtb_id_start...dtb_id_end,
age_group: 'overall')
.order(:ranking_position, dtb_id: :desc)
end
#
# Extract the gender from the filename.
#
# @param [String] filename filename to extract period from
#
# @return [Integer] gender factor
#
def self.extract_gender_from_filename(filename)
logger.debug "extracting gender part from file '#{filename}'"
filename_without_path = filename.split('/').last
if filename_without_path.include? 'Junioren'
100
else
200
end
end
private_class_method :create_time_from_string, :calculate_rankings
private_class_method :load_ranking_for_age_range, :save_ranking
private_class_method :rankings_for_age_range_in_period
private_class_method :extract_gender_from_filename
end
|
hwesselmann/ranking-info
|
test/controllers/clubs_controller_test.rb
|
# frozen_string_literal: true
require 'test_helper'
class ClubsControllerTest < ActionDispatch::IntegrationTest
test 'should get clubs' do
get clubs_path
assert_response :success
assert_select 'title', full_title('Vereinssuche')
end
test 'get club info' do
get club_path('Eintracht Frankfurt')
assert_response :success
assert_select 'title', full_title('Eintracht Frankfurt')
end
end
|
hwesselmann/ranking-info
|
app/controllers/federations_controller.rb
|
# frozen_string_literal: true
#
# Controller for federation data view.
#
class FederationsController < ApplicationController
def index
@federations = {}
quarter = current_quarter
return @federations if quarter.nil?
quarter = quarter.date
male_count = player_count_by_federation(quarter, 'm')
female_count = player_count_by_federation(quarter, 'w')
federations = {}
age_groups = {}
curr_fed = ''
# male counts
male_count.each do |entry|
unless entry['federation'].eql?(curr_fed)
federations[curr_fed] = age_groups unless curr_fed.eql?('')
age_groups = {}
curr_fed = entry['federation']
end
age_group = "#{entry['age_group']}m"
age_groups[age_group] = entry['count']
end
federations[curr_fed] = age_groups
# female counts
age_groups = {}
female_count.each do |entry|
age_group = "#{entry['age_group']}w"
federations[entry['federation']][age_group] = entry['count']
end
@federations = federations
end
def current_quarter
Ranking.select(:date).order(date: :desc)
.distinct.first
end
def player_count_by_federation(quarter, gender)
dtb_id = if gender.eql?('m') then 10_000_000
else 20_000_000
end
sql = "SELECT COUNT(dtb_id) AS count, federation, age_group FROM rankings
WHERE date='#{quarter}' AND dtb_id >= #{dtb_id}
AND dtb_id < #{dtb_id + 10_000_000}
AND yob_ranking=false AND age_group_ranking=true
AND year_end_ranking=false
GROUP BY federation, age_group;"
Ranking.find_by_sql(sql)
end
end
|
hwesselmann/ranking-info
|
test/controllers/federations_controller_test.rb
|
require 'test_helper'
class FederationsControllerTest < ActionDispatch::IntegrationTest
test 'get current quarter' do
sut = FederationsController.new
assert_instance_of(Ranking, sut.current_quarter)
assert_equal('2018-07-01', sut.current_quarter.date.strftime('%Y-%m-%d'))
end
end
|
hwesselmann/ranking-info
|
test/controllers/static_pages_controller_test.rb
|
<gh_stars>0
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
def setup
@base_title = 'Ranking-Info'
end
test 'should get home' do
get root_path
assert_response :success
assert_select 'title', full_title('')
end
test 'should get help' do
get help_path
assert_response :success
assert_select 'title', full_title('Hilfe')
end
test 'should get privacy' do
get privacy_path
assert_response :success
assert_select 'title', full_title('Datenschutz')
end
end
|
hwesselmann/ranking-info
|
app/controllers/import_controller.rb
|
# frozen_string_literal: true
#
# Controller for import and import status actions.
#
class ImportController < ApplicationController
before_action :logged_in_user, only: %i[upload import]
def info
# show some stats
@player_male_count = Ranking.select(:dtb_id).where('dtb_id >= 10000000 AND dtb_id < 20000000').distinct.count
@player_female_count = Ranking.select(:dtb_id).where('dtb_id >= 20000000 AND dtb_id < 30000000').distinct.count
@ranking_count = Ranking.count
@available_quarters = helpers.fetch_available_quarters
# last import
last_updated_db = Ranking.order(updated_at: :desc).first
last_updated = if last_updated_db.nil? then ''
else last_updated_db.updated_at.localtime('+02:00')
.strftime('%d.%m.%Y %H:%M')
end
@date_last_updated = last_updated
end
def upload; end
def import
if params[:file]
uploaded = params[:file]
File.open(Rails.root.join('public', 'uploads', uploaded.original_filename), 'wb') do |f|
f.write(uploaded.read)
end
Ranking.import_rankings("public/uploads/#{uploaded.original_filename}")
redirect_to status_url, flash: { info: "new rankings file
#{uploaded.original_filename} imported!" }
else
redirect_to status_url, flash: { info: 'please upload a ranking file' }
end
end
private
# Confirms a logged-in user.
def logged_in_user
return if logged_in?
flash[:danger] = 'Please log in to access import page'
redirect_to login_url
end
end
|
hwesselmann/ranking-info
|
test/controllers/import_controller_test.rb
|
<gh_stars>0
require 'test_helper'
class ImportControllerTest < ActionDispatch::IntegrationTest
def setup
@user = users(:testuser)
end
test 'should get status' do
get status_path
assert_response :success
assert_select 'title', full_title('Status')
end
test 'should redirect update when not logged in' do
get import_path
assert_not flash.empty?
assert_redirected_to login_url
end
end
|
hwesselmann/ranking-info
|
test/models/ranking_test.rb
|
<reponame>hwesselmann/ranking-info
# frozen_string_literal: true
require 'test_helper'
class RankingTest < ActiveSupport::TestCase
test 'period extraction from filename' do
sut = Ranking.extract_period_from_filename('Junioren_20180331.csv')
assert_equal(Time.new('2018', '3', '31'), sut)
sut = Ranking.extract_period_from_filename('Junioren_20121231.csv')
assert_equal(Time.new('2012', '12', '31'), sut)
end
test 'throw exception for invalid period extraction' do
exception = assert_raises RuntimeError do
Ranking.extract_period_from_filename('Junioren-20180331.csv')
end
exp = "could not retrieve period part from filename 'Junioren-20180331.csv'"
assert_equal(exp, exception.message)
end
test 'calculation of yob to fetch from db' do
date = Time.new('2019', '03', '31')
sut = Ranking.yob_range_to_fetch('2008', 11, date, 100)
assert_equal(108, sut.fetch(0))
assert_equal(1, sut.size)
sut = Ranking.yob_range_to_fetch('2008', 12, date, 100)
assert_equal(108, sut.fetch(0))
assert_equal(107, sut.fetch(1))
assert_equal(2, sut.size)
sut = Ranking.yob_range_to_fetch('2008', 14, date, 200)
assert_equal(208, sut.fetch(0))
assert_equal(206, sut.fetch(2))
assert_equal(4, sut.size)
sut = Ranking.yob_range_to_fetch('2008', 16, date, 200)
assert_equal(208, sut.fetch(0))
assert_equal(204, sut.fetch(4))
assert_equal(6, sut.size)
end
test 'full ranking_file_import' do
assert(File.exist?('./test/fixtures/files/Junioren_20180401.csv'))
assert(File.exist?('./test/fixtures/files/Juniorinnen_20180401.csv'))
assert_equal(4, Ranking.count)
Ranking.import_rankings('./test/fixtures/files/Junioren_20180401.csv')
Ranking.import_rankings('./test/fixtures/files/Juniorinnen_20180401.csv')
assert_equal(292, Ranking.count)
end
end
|
hwesselmann/ranking-info
|
db/migrate/20210924184238_create_rankings.rb
|
class CreateRankings < ActiveRecord::Migration[6.0]
def change
create_table :rankings do |t|
t.integer :dtb_id, index: true
t.string :firstname, limit: 50
t.string :lastname, limit: 50, index: true
t.string :federation, limit: 50, index: true
t.string :club, index: true
t.string :nationality, limit: 3
t.date :date
t.string :age_group
t.integer :ranking_position
t.string :score
t.boolean :age_group_ranking, default: false
t.boolean :yob_ranking, default: false
t.boolean :year_end_ranking, default: false
t.timestamps
end
add_index :rankings, [:dtb_id, :date]
add_index :rankings, [:dtb_id, :date, :federation]
end
end
|
hwesselmann/ranking-info
|
app/controllers/clubs_controller.rb
|
<reponame>hwesselmann/ranking-info<filename>app/controllers/clubs_controller.rb
# frozen_string_literal: true
#
# Controller for all actions concerning club data.
#
class ClubsController < ApplicationController
def index
clubs = []
if params[:commit]
quarter = current_quarter
player_clubs = find_all_clubs(quarter, params[:club])
player_clubs.each do |c|
player_count = count_players_for_club(quarter, c.club)
clubs.push({ name: c.club, player_count: player_count })
end
end
@clubs = clubs
end
def show
quarter = current_quarter
players = Ranking.where("date='#{quarter}' AND age_group='overall'
AND LOWER(club)=LOWER('#{params[:id]}')")
.order(:lastname)
player_ranking = fill_club_info(players, quarter)
@players = player_ranking
end
private
def current_quarter
Ranking.select(:date)
.order(date: :desc)
.distinct
.first
.date
end
def find_all_clubs(quarter, club)
Ranking.select(:club)
.where("date='#{quarter}' AND LOWER(club) LIKE LOWER('%#{club}%')")
.order(:club)
.distinct
end
def count_players_for_club(quarter, club)
Ranking.select(:dtb_id)
.where("date='#{quarter}' AND age_group='overall' AND club='#{club}'")
.count
end
def fill_club_info(players, quarter)
player_ranking = {}
u12_players = []
u14_players = []
u16_players = []
u18_players = []
players.each do |player|
player_data = fetch_basic_player_data(player, quarter)
case player_data[:age]
when 'U12'
u12_players.push(player_data)
when 'U14'
u14_players.push(player_data)
when 'U16'
u16_players.push(player_data)
when 'U18'
u18_players.push(player_data)
end
end
player_ranking['U12'] = u12_players unless u12_players.empty?
player_ranking['U14'] = u14_players unless u14_players.empty?
player_ranking['U16'] = u16_players unless u16_players.empty?
player_ranking['U18'] = u18_players unless u18_players.empty?
player_ranking
end
def fetch_basic_player_data(player, quarter)
ranking = Ranking.find_by(dtb_id: player.dtb_id,
age_group: 'overall',
date: quarter)
age_group = Ranking.find_by(dtb_id: player.dtb_id, date: quarter,
yob_ranking: false, age_group_ranking: true,
year_end_ranking: false)
.age_group
{ dtb_id: player.dtb_id, lastname: player.lastname,
firstname: player.firstname, score: ranking.score,
rank: ranking.ranking_position, age: age_group }
end
end
|
hwesselmann/ranking-info
|
test/helpers/application_helper_test.rb
|
require 'test_helper'
class ApplicationHelperTest < ActionView::TestCase
test 'full title helper' do
assert_equal full_title, 'Ranking-Info'
assert_equal full_title('About'), 'About | Ranking-Info'
end
test 'get available quarters' do
assert_equal(2, fetch_available_quarters.size)
assert_equal(2, fetch_available_quarters['2017'].size)
assert_equal('01.07.', fetch_available_quarters['2018'].fetch(0))
end
test 'get federation long name' do
assert_equal('Baden', federation_long_name('BAD'))
assert_equal('Berlin-Brandenburg', federation_long_name('BB'))
assert_equal('Bayern', federation_long_name('BTV'))
assert_equal('Hamburg', federation_long_name('HAM'))
assert_equal('Hessen', federation_long_name('HTV'))
assert_equal('Rheinland-Pfalz', federation_long_name('RPF'))
assert_equal('Schleswig-Holstein', federation_long_name('SLH'))
assert_equal('Saarland', federation_long_name('STB'))
assert_equal('Sachsen', federation_long_name('STV'))
assert_equal('Mecklenburg-Vorpommern', federation_long_name('TMV'))
assert_equal('Niedersachsen-Bremen', federation_long_name('TNB'))
assert_equal('Sachsen-Anhalt', federation_long_name('TSA'))
assert_equal('Thüringen', federation_long_name('TTV'))
assert_equal('Mittelrhein', federation_long_name('TVM'))
assert_equal('Niederrhein', federation_long_name('TVN'))
assert_equal('Würtemberg', federation_long_name('WTB'))
assert_equal('Westfalen', federation_long_name('WTV'))
assert_equal('HTI', federation_long_name('HTI'))
end
end
|
hwesselmann/ranking-info
|
app/models/club.rb
|
<reponame>hwesselmann/ranking-info<gh_stars>0
# frozen_string_literal: true
#
# Model for a club of a player on the ranking (this is a transient object)
#
class Club
attr_accessor :name, :federation
end
|
hwesselmann/ranking-info
|
test/integration/clubs_search_test.rb
|
require 'test_helper'
class ClubsSearchTest < ActionDispatch::IntegrationTest
test 'check club search page' do
get clubs_path
assert_template 'clubs/index'
assert assigns(:clubs)
assert_template partial: 'clubs/_search_intro'
end
test 'check club result list' do
get clubs_path, params: { commit: 'suchen', club: 'BVH' }
assert_response :success
assert assigns(:clubs)
assert_template 'clubs/index'
assert_select 'div', 'Es wurden keine Vereine gefunden.'
end
end
|
hwesselmann/ranking-info
|
app/controllers/players_controller.rb
|
<reponame>hwesselmann/ranking-info
# frozen_string_literal: true
#
# Player controller for all actions on Tennis players.
#
class PlayersController < ApplicationController
def index
if params[:dtb_id] && !params[:dtb_id].eql?('')
search_dtb_id = params[:dtb_id].strip
dtb_id_start = fill_up_dtb_id(search_dtb_id.to_i)
dtb_id_end = fill_up_dtb_id_end(search_dtb_id.to_i)
@players = Player.find_players_by_dtb_id(dtb_id_start, dtb_id_end)
# should return exactly one match => redirect to profile
redirect_to action: 'show', id: search_dtb_id if @players.size == 1
elsif params[:lastname] && !params[:lastname].eql?('')
# fuzzy!
s_lastname = params[:lastname].strip
if params[:yob] && !params[:yob].eql?('')
# fuzzy lastname in yob
s_yob = params[:yob].strip
yob_male = s_yob[2, 4].to_i + 100
yob_female = yob_male + 100
@players = Player.find_players_by_lastname_and_yob(s_lastname, yob_male, yob_female)
else
@players = Player.find_players_by_lastname(s_lastname)
end
redirect_to action: 'show', id: @players[0].dtb_id if @players.size == 1
elsif params[:yob] && !params[:yob].eql?('')
s_yob = params[:yob].strip
yob_male = s_yob[2, 4].to_i + 100
yob_female = yob_male + 100
@players = Player.find_players_by_yob(yob_male, yob_female)
redirect_to action: 'show', id: @players[0].dtb_id if @players.size == 1
elsif params[:commit]
# search was fired without parameters => show all
@players = Player.find_all_players
end
end
def show
@player = Player.load_player_profile(params[:id])
@available_quarters = helpers.fetch_available_quarters(dtb_id: @player.dtb_id)
@current_rankings = get_current_rankings(@player.dtb_id)
@complete_rankings = get_complete_rankings(@player.dtb_id).reverse!
@data_for_last_twelve_months = data_for_last_twelve_months(@player.dtb_id)[0]
@score_for_last_twelve_months = data_for_last_twelve_months(@player.dtb_id)[1]
@data_diagram_complete = data_diagram_complete(@player.dtb_id)[0]
@score_diagram_complete = data_diagram_complete(@player.dtb_id)[1]
rescue StandardError
redirect_to players_path, flash: { danger: 'Spieler nicht gefunden' }
end
def fill_up_dtb_id(dtb_id_part)
return dtb_id_part if dtb_id_part.digits.length.eql?(8)
dtb_id = dtb_id_part
(8 - dtb_id_part.digits.length).times do
dtb_id *= 10
end
dtb_id
end
def fill_up_dtb_id_end(dtb_id_part)
return dtb_id_part if dtb_id_part.digits.length.eql?(8)
dtb_id = dtb_id_part
fill = ''
(8 - dtb_id_part.digits.length).times do
dtb_id *= 10
fill += '9'
end
dtb_id + fill.to_i
end
private
def get_current_rankings(dtb_id)
rankings = []
# 1. get the latest available period for player.
# If nothing is available => message
current_quarter = Ranking.select(:date)
.order(date: :desc)
.distinct
.first
.date
# 2. get rankings for that period
current_rankings = Ranking.where(dtb_id: dtb_id, date: current_quarter,
yob_ranking: false,
age_group_ranking: false,
year_end_ranking: false)
.order(:age_group)
if current_rankings.size.positive?
current_rankings.each do |current_ranking|
ranking = {}
# 3. fill the initial hash
next if current_ranking.age_group.eql?('overall')
ranking['age_group'] = current_ranking.age_group
ranking['position'] = current_ranking.ranking_position
ranking['score'] = current_ranking.score
# 4. get rankings of period - 1
older_quarters_available = Ranking.select(:date)
.where(dtb_id: dtb_id)
.order(date: :desc)
.distinct.size
if older_quarters_available > 1
previous_quarter = Ranking.select(:date)
.order(date: :desc)
.distinct[1]
.date
# 5. calculate differences
prev_ranking = Ranking.find_by(dtb_id: dtb_id,
age_group: current_ranking.age_group,
date: previous_quarter,
yob_ranking: false,
age_group_ranking: false,
year_end_ranking: false)
position_change = prev_ranking.ranking_position - current_ranking.ranking_position
ranking['position_change'] = if position_change.positive?
then "+#{position_change}"
else position_change.to_s
end
score_change = current_ranking.score.to_f - prev_ranking.score.to_f
ranking['score_change'] = if score_change.positive?
then "+#{score_change}"
else score_change.to_s
end
end
rankings.push(ranking)
end
end
rankings
end
def get_complete_rankings(dtb_id)
db_rankings = Ranking.where(dtb_id: dtb_id, yob_ranking: false,
age_group_ranking: false,
year_end_ranking: false)
.order(:date, :age_group)
rankings = []
ranking = {}
start_year = 0
current_quarter = ''
db_rankings.each do |ran|
case ran.date.month
when 1
quarter = 'Q1'
when 4
quarter = 'Q2'
when 7
quarter = 'Q3'
when 10
quarter = 'Q4'
end
if start_year.eql?(ran.date.year)
if current_quarter.eql?(quarter)
# same year, same quarter => add age group
ranking[ran.age_group] = ran.ranking_position
else
# same year, other quarter => push and start new
rankings.push(ranking)
current_quarter = quarter
ranking = {}
ranking['year'] = ran.date.year
ranking['quarter'] = quarter
ranking[ran.age_group] = ran.ranking_position
ranking['score'] = ran.score
end
else
# different year => check if first run and start new
rankings.push(ranking) unless start_year.eql?(0)
start_year = ran.date.year
current_quarter = quarter
ranking = {}
ranking['year'] = ran.date.year
ranking['quarter'] = quarter
ranking[ran.age_group] = ran.ranking_position
ranking['score'] = ran.score
end
end
rankings.push(ranking)
rankings
end
def data_for_last_twelve_months(dtb_id)
rankings = Ranking.where(dtb_id: dtb_id, yob_ranking: false,
age_group_ranking: true, year_end_ranking: false)
.order(date: :desc, age_group: :asc)
.limit(4)
diagram_data = []
diagram_data.push(collect_diagram_data(rankings))
diagram_data.push(collect_score_data(rankings))
diagram_data
end
def data_diagram_complete(dtb_id)
rankings = Ranking.where(dtb_id: dtb_id, yob_ranking: false,
age_group_ranking: false, year_end_ranking: false)
.order(date: :desc, age_group: :asc)
diagram_data = []
diagram_data.push(collect_diagram_data(rankings))
diagram_data.push(collect_score_data(rankings))
diagram_data
end
def collect_diagram_data(rankings)
u12_pos = {}
u14_pos = {}
u16_pos = {}
u18_pos = {}
rankings.reverse_each do |ranking|
period = (ranking.date - 1.day).strftime('%d.%m.%Y')
case ranking.age_group
when 'U12'
u12_pos[period] = ranking.ranking_position
when 'U14'
u14_pos[period] = ranking.ranking_position
when 'U16'
u16_pos[period] = ranking.ranking_position
when 'U18'
u18_pos[period] = ranking.ranking_position
end
end
diagram_data = []
diagram_data.push({ name: 'U12', data: u12_pos }) if u12_pos.size.positive?
diagram_data.push({ name: 'U14', data: u14_pos }) if u14_pos.size.positive?
diagram_data.push({ name: 'U16', data: u16_pos }) if u16_pos.size.positive?
diagram_data.push({ name: 'U18', data: u18_pos }) if u18_pos.size.positive?
diagram_data
end
def collect_score_data(rankings)
scores = {}
rankings.reverse_each do |ranking|
period = (ranking.date - 1.day).strftime('%d.%m.%Y')
scores[period] = ranking.score
end
[{ name: 'Punkte', data: scores, vAxis: 0 }]
end
end
|
hwesselmann/ranking-info
|
app/controllers/static_pages_controller.rb
|
# frozen_string_literal: true
#
# Controller for static content.
#
class StaticPagesController < ApplicationController
def home
first_import = Ranking.select(:date)
.order(date: :desc)
.distinct
.last
@start = if first_import.nil? then 'xx.xx.xxxx'
else first_import.date.strftime('%d.%m.%Y')
end
end
def help; end
def about; end
def privacy; end
end
|
hwesselmann/ranking-info
|
test/controllers/players_controller_test.rb
|
<reponame>hwesselmann/ranking-info<gh_stars>0
require 'test_helper'
class PlayersControllerTest < ActionDispatch::IntegrationTest
test 'should get players' do
get players_path
assert_response :success
assert_select 'title', full_title('Spielersuche')
end
test 'should get player profile' do
get player_path(10_711_111)
assert_response :success
assert_select 'title', full_title('Spielerprofil J****<NAME>****y')
end
test 'filling up dtb_id' do
sut = PlayersController.new
assert_equal(10_812_345, sut.fill_up_dtb_id(10_812_345))
assert_equal(10_000_000, sut.fill_up_dtb_id(1))
assert_equal(10_000_000, sut.fill_up_dtb_id(10))
assert_equal(20_800_000, sut.fill_up_dtb_id(208))
end
test 'filling up dtb_id end' do
sut = PlayersController.new
assert_equal(10_812_345, sut.fill_up_dtb_id_end(10_812_345))
assert_equal(19_999_999, sut.fill_up_dtb_id_end(1))
assert_equal(10_999_999, sut.fill_up_dtb_id_end(10))
assert_equal(20_899_999, sut.fill_up_dtb_id_end(208))
end
end
|
hwesselmann/ranking-info
|
test/models/player_test.rb
|
# frozen_string_literal: true
require 'test_helper'
class PlayerTest < ActiveSupport::TestCase
end
|
hwesselmann/ranking-info
|
app/models/player.rb
|
# frozen_string_literal: true
#
# Model for a player on the ranking (this is a transient object)
#
class Player
def self.load_player_profile(dtb_id)
player = Player.new
current_data = Ranking.where(dtb_id: dtb_id, age_group: 'overall').order(date: :desc).first
player.dtb_id = dtb_id
player.lastname = current_data.lastname
player.firstname = current_data.firstname
player.nationality = current_data.nationality
player.club = current_data.club
player.federation = current_data.federation
player.clubs = player.fetch_clubs(dtb_id)
player
end
def fetch_clubs(dtb_id)
clubs = []
all_clubs_from_rankings = Ranking.where(dtb_id: dtb_id, age_group: 'overall').order(date: :desc)
last_club = ''
all_clubs_from_rankings.each do |item|
next if last_club.eql?(item.club)
club = Club.new
club.name = item.club
club.federation = item.federation
clubs.push club
last_club = item.club
end
clubs
end
def self.find_all_players
players_to_filter = Ranking.select(:dtb_id, :lastname, :firstname, :federation, :club, :nationality, :date)
.order(:lastname, :dtb_id, date: :desc).distinct
players = []
last_dtb_id = 0
players_to_filter.each do |player|
next if last_dtb_id.eql?(player.dtb_id)
players.push(player)
last_dtb_id = player.dtb_id
end
players
end
def self.find_players_by_lastname(lastname)
players_to_filter = Ranking.select(:dtb_id, :lastname, :firstname, :club, :federation, :nationality, :date)
.where("LOWER(lastname) LIKE LOWER('%#{lastname}%')")
.order(:lastname, :dtb_id, date: :desc)
.distinct
players = []
last_dtb_id = 0
players_to_filter.each do |player|
next if last_dtb_id.eql?(player.dtb_id)
players.push(player)
last_dtb_id = player.dtb_id
end
players
end
def self.find_players_by_lastname_and_yob(lastname, yob_male, yob_female)
players_to_filter = Ranking.select(:dtb_id, :lastname, :firstname, :federation, :club, :nationality)
.where("LOWER(lastname) LIKE LOWER('%#{lastname}%')
AND ((dtb_id >= #{yob_male * 100_000}
AND dtb_id <= #{yob_male * 100_000 + 99_999})
OR (dtb_id>= #{yob_female * 100_000}
AND dtb_id <= #{yob_female * 100_000 + 99_999}))")
.order(:lastname, :dtb_id, date: :desc)
.distinct
players = []
last_dtb_id = 0
players_to_filter.each do |player|
next if last_dtb_id.eql?(player.dtb_id)
players.push(player)
last_dtb_id = player.dtb_id
end
players
end
def self.find_players_by_dtb_id(dtb_id_start, dtb_id_end)
players_to_filter = Ranking.select(:dtb_id, :lastname, :firstname, :federation, :club, :nationality)
.where("dtb_id >= #{dtb_id_start}
AND dtb_id <= #{dtb_id_end}")
.order(:lastname, :dtb_id, date: :desc)
.distinct
players = []
last_dtb_id = 0
players_to_filter.each do |player|
next if last_dtb_id.eql?(player.dtb_id)
players.push(player)
last_dtb_id = player.dtb_id
end
players
end
def self.find_players_by_yob(yob_male, yob_female)
players_to_filter = Ranking.select(:dtb_id, :lastname, :firstname, :federation, :club, :nationality)
.where("(dtb_id >= #{yob_male * 100_000}
AND dtb_id <= #{yob_male * 100_000 + 99_999})
OR (dtb_id >= #{yob_female * 100_000}
AND dtb_id <= #{yob_female * 100_000 + 99_999})")
.order(:lastname, :dtb_id, date: :desc)
.distinct
players = []
last_dtb_id = 0
players_to_filter.each do |player|
next if last_dtb_id.eql?(player.dtb_id)
players.push(player)
last_dtb_id = player.dtb_id
end
players
end
attr_accessor :dtb_id, :current_ranking, :current_score, :lastname, :firstname
attr_accessor :federation, :club, :nationality, :clubs, :rankings
end
|
aarowill/dotfiles
|
lib/dotfile_commands/git.rb
|
<gh_stars>1-10
require 'dotfile_command_base'
require 'git'
module DotfilesCli
module DotfileCommands
class Git < DotfileCommandBase
desc '[Options]', 'generate gitconfig from template'
class_option 'git-user', desc: 'The user name to put in the gitconfig'
class_option 'git-email', desc: 'The user email to put in the gitconfig'
class_option 'git-push', desc: 'What value to use for push.default in the gitconfig'
class_option 'git-mergetool', desc: 'What value to use for merge.tool in the gitconfig'
class_option 'git-difftool', desc: 'What value to use for diff.tool in the gitconfig'
def setup(*_args)
return unless executable_in_path?('git')
# Set up git config
gitconfig
end
private
def gitconfig
dest_config = File.join(options[:destination], '.gitconfig')
fancy_diff = executable_in_path?('diff-so-fancy')
(user, email) = user_and_email
(mergetool, difftool) = tools
# Determine git version
git_version = Gem::Version.new(Open3.capture2('git --version').first.split("\s").last)
push = options['git-push']
if git_version >= Gem::Version.new('2.1.8')
push = 'upstream' if push.nil?
diff = 'patience'
end
submodule = if git_version >= Gem::Version.new('2.11.0')
'diff'
else
'log'
end
decorate_color = if git_version >= Gem::Version.new('1.8.3')
'auto'
else
'bold yellow'
end
template(File.join(options[:templates], 'gitconfig.erb'),
dest_config,
submodule: submodule,
diff: diff,
push: push,
user: user,
email: email,
fancy_diff: fancy_diff,
decorate_color: decorate_color,
mergetool: mergetool,
difftool: difftool)
end
def user_and_email
# Set these to the empty string if they're not defined so that we can always use .empty?
user = options['git-user'] || ''
email = options['git-email'] || ''
# Attempt to determine user and/or email from existing config
user = ::Git.global_config('user.name') if user.empty?
email = ::Git.global_config('user.email') if email.empty?
# Don't create a config without user and email
if user.empty? || email.empty?
say 'ERROR (Git): could not determine gitconfig email and/or user', :red
raise Thor::MissingArgumentError
end
[user, email]
end
def tools
# Set these to the empty string if they're not defined so that we can always use .empty?
mergetool = options['git-mergetool'] || ''
difftool = options['git-difftool'] || ''
# Attempt to determine merge/diff tools from existing config
mergetool = ::Git.global_config('merge.tool') if mergetool.empty?
difftool = ::Git.global_config('diff.tool') if difftool.empty?
# Default to vimdiff for both merge and diff tools
mergetool = 'vimdiff' if mergetool.empty?
difftool = 'vimdiff' if difftool.empty?
[mergetool, difftool]
end
end
end
end
|
lyzkov/SinkEmAll
|
SinkEmAll.podspec
|
<reponame>lyzkov/SinkEmAll<filename>SinkEmAll.podspec
Pod::Spec.new do |s|
s.name = 'SinkEmAll'
s.version = '0.1.0'
s.summary = 'An error handling reactive extension for fine-grained control over Abort, Retry, Fail?'
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
An error handling reactive extension for fine-grained control over [Abort, Retry, Fail?](https://en.wikipedia.org/wiki/Abort,_Retry,_Fail%3F)
> Battleship (also Battleships or Sea Battle) is a guessing game for two players. It is played on ruled grids (paper or board) on which each player's fleet of ships (including battleships) are marked. The locations of the fleets are concealed from the other player. Players alternate turns calling "shots" at the other player's ships, and the objective of the game is to destroy the opposing player's fleet.
## Usage
SinkEmAll extends the way of handling errors in RxSwift. It brings (A)bort, (R)etry, (F)ail? pattern back to the game. Yes, that's the battleship game!
```swift
/// Definition of a single attempt of handling error.
/// That's the battleship game: you can miss, hit, or sink on target.
///
/// - miss: Attempt the operation again. (R)etry
/// - hit: Throw an error to the next handler in the chain of responsibility. (A)bort or (I)gnore
/// - sink: Gracefully recover from an error. (F)ail
public enum Shot {
case miss
case hit(Error)
case sink
}
```
DESC
s.homepage = 'https://github.com/lyzkov/SinkEmAll'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'lyzkov' => '<EMAIL>' }
s.source = { :git => 'https://github.com/lyzkov/SinkEmAll.git', :tag => s.version.to_s }
s.ios.deployment_target = '10.0'
s.source_files = 'Sources/**/*'
s.dependency 'RxSwift', '~> 5'
s.swift_version = '5.0'
end
|
Digipolitan/dependency-injector-object-mapper-swift
|
DependencyInjectorObjectMapper.podspec
|
Pod::Spec.new do |s|
s.name = "DependencyInjectorObjectMapper"
s.version = "1.0.6"
s.summary = "Add Mappable support with dependency injection"
s.homepage = "https://github.com/Digipolitan/dependency-injector-object-mapper"
s.authors = "Digipolitan"
s.source = { :git => "https://github.com/Digipolitan/dependency-injector-object-mapper.git", :tag => "v#{s.version}" }
s.license = { :type => "BSD", :file => "LICENSE" }
s.source_files = 'Sources/**/*.{swift,h}'
s.ios.deployment_target = '8.0'
s.watchos.deployment_target = '2.0'
s.tvos.deployment_target = '9.0'
s.osx.deployment_target = '10.10'
s.swift_version = '5.0'
s.dependency 'DependencyInjector', '~> 2.2'
s.dependency 'ObjectMapper', '~> 3.4'
end
|
dvlproad/001-UIKit-CJTS-iOS
|
TSDemo_Demo.podspec
|
Pod::Spec.new do |s|
#验证方法1:pod lib lint TSDemo_Demo.podspec --sources='https://github.com/CocoaPods/Specs.git,https://gitee.com/dvlproad/dvlproadSpecs' --allow-warnings --use-libraries --verbose
#验证方法2:pod lib lint TSDemo_Demo.podspec --sources=master,dvlproad --allow-warnings --use-libraries --verbose
#提交方法: pod trunk push TSDemo_Demo.podspec --allow-warnings --use-libraries --verbose
s.name = "TSDemo_Demo"
s.version = "0.5.2"
s.summary = "浮层弹窗Overlay演示示例"
s.homepage = "https://github.com/dvlproad/001-UIKit-CQDemo-iOS.git"
#s.license = "MIT"
s.license = {
:type => 'Copyright',
:text => <<-LICENSE
© 2008-2016 dvlproad. All rights reserved.
LICENSE
}
s.author = { "dvlproad" => "" }
s.description = <<-DESC
-、演示示例
A longer description of TSDemo_Demo in Markdown format.
* Think: Why did you write this? What is the focus? What does it do?
* CocoaPods will be using this to generate tags, and improve search results.
* Try to keep it short, snappy and to the point.
* Finally, don't worry about the indent, CocoaPods strips it!
DESC
s.platform = :ios, "8.0"
s.source = { :git => "https://github.com/dvlproad/001-UIKit-CQDemo-iOS.git", :tag => "TSDemo_Demo_0.5.2" }
#s.source_files = "CJDemoCommon/*.{h,m}"
#s.source_files = "CJChat/TestOSChinaPod.{h,m}"
s.frameworks = "UIKit"
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4"
# TSDemo_Demo
s.source_files = "TSDemo_Demo/**/*.{h,m}"
# s.resource_bundle = {
# 'TSDemo_Demo' => ['TSDemo_Demo/**/*.xcassets', 'TSDemo_Demo/**/*.{png,jpg}'] # CQShareSheet 为生成boudle的名称,可以随便起,但要记住,库里要用
# }
#多个依赖就写多行
s.dependency 'CQDemoKit'
end
|
LinQTeam/miyabi
|
lib/check.rb
|
class String
def is_hira?
return true if self =~ /\p{hiragana}|\p{hiragana}[0-9][0-9]/
false
end
def is_japanese?
return true if self =~ /\A(?:\p{Hiragana}|\p{Katakana}|[ー-]|[一-龠々])+\z/
false
end
def is_kana?
return true if self =~ /\p{katakana}|\p{katakana}[0-9][0-9]/
false
end
def is_kanji?
return true if self =~ /^[一-龥]+$/
false
end
def is_roman?
return true if self =~ /^[a-zA-Z0-90-9]+$/
false
end
end
|
LinQTeam/miyabi
|
spec/miyabi/format_spec.rb
|
require "spec_helper"
RSpec.describe "format" do
describe "#to_kana" do
subject { text.to_kana }
let(:text) { "ひらがな" }
context "when hiragana" do
it { is_expected.to eq "ヒラガナ" }
end
context "when katakana" do
let(:text) { "カタカナ" }
it { is_expected.to eq "カタカナ" }
end
context "when hiragana with katakana" do
let(:text) { "ひらがなカタカナ" }
it { is_expected.to eq "ヒラガナカタカナ" }
end
context "when romaji" do
let(:text) { "romaji" }
it { is_expected.to eq "romaji" }
end
context "when kanji" do
let(:text) { "漢字" }
it { is_expected.to eq "漢字" }
end
end
describe "#to_hira" do
subject { text.to_hira }
let(:text) { "カタカナ" }
context "when katakana" do
it { is_expected.to eq "かたかな" }
end
context "when hiragana" do
let(:text) { "ひらがな" }
it { is_expected.to eq "ひらがな" }
end
context "when katakana with hiragana" do
let(:text) { "カタカナひらがな" }
it { is_expected.to eq "かたかなひらがな" }
end
context "when katakana with kanji" do
let(:text) { "カタカナ日本語" }
it { is_expected.to eq "かたかな日本語" }
end
end
describe "#to_roman" do
subject { text.to_roman }
let(:text) { "ひらがな" }
context "when hiragana" do
it { is_expected.to eq "hiragana" }
end
context "when romaji with number" do
let(:text) { "romaji01234" }
it { is_expected.to eq text }
end
context "when hiragana with half size number" do
let(:text) { "ひらがな01234" }
it { is_expected.to eq "hiragana01234" }
end
context "when hiragana with em number" do
let(:text) { "ひらがな01234" }
it { is_expected.to eq "hiragana01234" }
end
context "when katakana" do
let(:text) { "カタカナ" }
it { is_expected.to eq "katakana" }
end
context "when katakana with number" do
let(:text) { "カタカナ01234" }
it { is_expected.to eq "katakana01234" }
end
context "when katakana with em number" do
let(:text) { "カタカナ01234" }
it { is_expected.to eq "katakana01234" }
end
context "when hiragana with katakana" do
let(:text) { "ひらがなカタカナ" }
it { is_expected.to eq "hiraganakatakana" }
end
context "when hiragana with kanji" do
let(:text) { "ひらがな漢字" }
it { is_expected.to eq "hiragana" }
end
context "when hiragana with romaji and kanji" do
let(:text) { "ひらがな漢字mix" }
it { is_expected.to eq "hiragana" }
end
context "when hiragana with special character" do
let(:text) { "ひらがな!" }
it { is_expected.to eq "hiragana" }
end
end
end
|
LinQTeam/miyabi
|
spec/miyabi_spec.rb
|
require "spec_helper"
RSpec.describe Miyabi do
it "has a version number" do
expect(Miyabi::VERSION).not_to be nil
end
end
|
LinQTeam/miyabi
|
spec/miyabi/check_spec.rb
|
require "spec_helper"
RSpec.describe "check" do
describe "#is_hira?" do
subject { text.is_hira? }
let(:text) { "ひらがな" }
context "when hiragana" do
it { is_expected.to be_truthy }
end
context "when hiragana with number" do
let(:text) { "ひらがな01234" }
it { is_expected.to be_truthy }
end
context "when hiragana with em number" do
let(:text) { "ひらがな01234" }
it { is_expected.to be_truthy }
end
context "when romaji" do
let(:text) { "hiragana" }
it { is_expected.to be_falsey }
end
context "when romaji with number" do
let(:text) { "hiragana01234" }
it { is_expected.to be_falsey }
end
context "when not hiragana" do
let(:text) { "カタカナ" }
it { is_expected.to be_falsey }
end
context "when includes hiragana" do
let(:text) { "ひらがなカタカナ" }
it { is_expected.to be_truthy }
end
context "when hiragana with emoji" do
let(:text) { "😉ひらがな" }
it { is_expected.to be_truthy }
end
context "when hiragana with special charactor" do
let(:text) { "𓇼𖠋𓆫𓀤𓆉𓆡ひらがな" }
it { is_expected.to be_truthy }
end
end
describe "#is_kana?" do
subject { text.is_kana? }
let(:text) { "カタカナ" }
context "when katakana" do
it { is_expected.to be_truthy }
end
context "when hiragana" do
let(:text) { "ひらがな" }
it { is_expected.to be_falsey }
end
context "when romaji" do
let(:text) { "katakana" }
it { is_expected.to be_falsey }
end
context "when number" do
let(:text) { "0123" }
it { is_expected.to be_falsey }
end
context "when katakana with number" do
let(:text) { "カキクケコ0123" }
it { is_expected.to be_truthy }
end
context "when number" do
let(:text) { "01234" }
it { is_expected.to be_falsey }
end
context "when katakana with em number" do
let(:text) { "カキクケコ01234" }
it { is_expected.to be_truthy }
end
context "when includes katakana" do
let(:text) { "ひらがなカタカナ" }
it { is_expected.to be_truthy }
end
context "when katakana with emoji" do
let(:text) { "😉カタカナ" }
it { is_expected.to be_truthy }
end
context "when hiragana with special charactor" do
let(:text) { "𓇼𖠋𓆫𓀤𓆉𓆡カタカナ" }
it { is_expected.to be_truthy }
end
end
describe "#is_kanji?" do
subject { text.is_kanji? }
let(:text) { "漢字" }
context "when kanji" do
it { is_expected.to be_truthy }
end
context "when hiragana" do
let(:text) { "ひらがな" }
it { is_expected.to be_falsey }
end
context "when kanji with hiragana" do
let(:text) { "明日は晴れ" }
it { is_expected.to be_falsey }
end
context "when kanji with katanaka" do
let(:text) { "快晴🌞" }
it { is_expected.to be_falsey }
end
end
describe "#is_japanese?" do
subject { text.is_japanese? }
let(:text) { "明日は晴れ" }
context "when japanese" do
it { is_expected.to be_truthy }
end
context "when japanese with !" do
let(:text) { "明日は晴れ!" }
it { is_expected.to be_falsey }
end
end
describe "#is_roman?" do
subject { text.is_roman? }
let(:text) { "romaji" }
context "when romaji" do
it { is_expected.to be_truthy }
end
context "when includes number" do
let(:text) { "romaji0123" }
it { is_expected.to be_truthy }
end
context "when includes number" do
let(:text) { "romaji1234" }
it { is_expected.to be_truthy }
end
context "when hiragana" do
let(:text) { "ひらがな" }
it { is_expected.to be_falsey }
end
context "when katakana" do
let(:text) { "カタカナ" }
it { is_expected.to be_falsey }
end
end
end
|
madebymany/browserify-rails
|
test/compilation_test.rb
|
<gh_stars>0
require 'test_helper'
class BrowserifyTest < ActionController::IntegrationTest
setup do
Rails.application.assets.cache = nil
FileUtils.cp(File.join(Rails.root, 'app/assets/javascripts/application.js.example'), File.join(Rails.root, 'app/assets/javascripts/application.js'))
FileUtils.cp(File.join(Rails.root, 'app/assets/javascripts/foo.js.example'), File.join(Rails.root, 'app/assets/javascripts/foo.js'))
FileUtils.cp(File.join(Rails.root, 'app/assets/javascripts/nested/index.js.example'), File.join(Rails.root, 'app/assets/javascripts/nested/index.js'))
end
test "asset pipeline should serve application.js" do
expected_output = fixture("application.out.js")
get "/assets/application.js"
assert_response :success
assert_equal expected_output, @response.body.strip
end
test "asset pipeline should serve foo.js" do
expected_output = fixture("foo.out.js")
get "/assets/foo.js"
assert_response :success
assert_equal expected_output, @response.body.strip
end
test "asset pipeline should regenerate application.js when foo.js changes" do
expected_output = fixture("application.out.js")
get "/assets/application.js"
assert_response :success
assert_equal expected_output, @response.body.strip
# Ensure that Sprockets can detect the change to the file modification time
sleep 1
File.open(File.join(Rails.root, 'app/assets/javascripts/foo.js'), 'w+') do |f|
f.puts "require('./nested');"
f.puts "module.exports = function (n) { return n * 12 }"
end
expected_output = fixture("application.foo_changed.out.js")
get "/assets/application.js"
assert_response :success
assert_equal expected_output, @response.body.strip
end
test "asset pipeline should regenerate application.js when application.js changes" do
expected_output = fixture("application.out.js")
get "/assets/application.js"
assert_response :success
assert_equal expected_output, @response.body.strip
# Ensure that Sprockets can detect the change to the file modification time
sleep 1
File.open(File.join(Rails.root, 'app/assets/javascripts/application.js'), 'w+') do |f|
f.puts "var foo = require('./foo');"
f.puts "console.log(foo(11));"
end
expected_output = fixture("application.changed.out.js")
get "/assets/application.js"
assert_response :success
assert_equal expected_output, @response.body.strip
end
test "throws BrowserifyError if something went wrong while executing browserify" do
File.open(File.join(Rails.root, 'app/assets/javascripts/application.js'), 'w+') do |f|
f.puts "var foo = require('./foo');"
f.puts "var bar = require('./bar');"
end
get "/assets/application.js"
assert_match /BrowserifyRails::BrowserifyError/, @response.body
end
def fixture(filename)
File.open(File.join(File.dirname(__FILE__), "/fixtures/#{filename}")).read.strip
end
end
|
madebymany/browserify-rails
|
lib/browserify-rails/browserify_processor.rb
|
require "open3"
require "json"
module BrowserifyRails
class BrowserifyProcessor < Tilt::Template
BROWSERIFY_CMD = "./node_modules/.bin/browserify".freeze
def prepare
end
def evaluate(context, locals, &block)
if commonjs_module?
asset_dependencies(context.environment.paths).each do |path|
context.depend_on(path)
end
browserify
else
data
end
end
private
def commonjs_module?
data.to_s.include?("module.exports") || data.to_s.include?("require")
end
# This primarily filters out required files from node modules
#
# @return [<String>] Paths of dependencies, that are in asset directories
def asset_dependencies(asset_paths)
dependencies.select do |path|
path.start_with?(*asset_paths)
end
end
# @return [<String>] Paths of files, that this file depends on
def dependencies
run_browserify("--list").lines.map(&:strip).select do |path|
# Filter the temp file, where browserify caches the input stream
File.exists?(path)
end
end
def browserify
# Only generate source maps in development
options = []
options << "-d" if Rails.env == "development"
options << "-t browserify-shim"
run_browserify(options.join(" "))
end
def browserify_cmd
cmd = File.join(Rails.root, BROWSERIFY_CMD)
if !File.exist?(cmd)
raise BrowserifyRails::BrowserifyError.new("browserify could not be found at #{cmd}. Please run npm install.")
end
cmd
end
# Run browserify with `data` on standard input.
#
# We are passing the data via stdin, so that earlier preprocessing steps are
# respected. If you had, say, an "application.js.coffee.erb", passing the
# filename would fail, because browserify would read the original file with
# ERB tags and fail. By passing the data via stdin, we get the expected
# behavior of success, because everything has been compiled to plain
# javascript at the time this processor is called.
#
# @raise [BrowserifyRails::BrowserifyError] if browserify does not succeed
# @param options [String] Options for browserify
# @return [String] Output on standard out
def run_browserify(options)
command = "#{browserify_cmd} #{options}"
directory = File.dirname(file)
stdout, stderr, status = Open3.capture3(command, stdin_data: data, chdir: directory)
if !status.success?
raise BrowserifyRails::BrowserifyError.new("Error while running `#{command}`:\n\n#{stderr}")
end
stdout
end
end
end
|
DocSpring/openapi-generator-mirror
|
examples/ruby/generate_pdf_async.rb
|
<reponame>DocSpring/openapi-generator-mirror
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This example demonstrates generating a PDF from a preconfigured template,
# and NOT waiting for the PDF to be processed.
#
# You can run this example with: ./examples/ruby/generate_pdf_async.rb
Dir.chdir File.join(File.dirname(__FILE__), '../../clients/ruby')
require 'bundler/setup'
Bundler.require
# This is a real test API token and template on docspring.com
# -------------------------------------------------------------
API_TOKEN_ID = '<KEY>'
API_TOKEN_SECRET = '<KEY>'
TEMPLATE_ID = '6zz3dYRYM67fxMXA'
begin
DocSpring.configure do |c|
c.username = API_TOKEN_ID # Your API Token ID
c.password = <PASSWORD>_TOKEN_SECRET # Your API Token Secret
# c.debugging = true
end
docspring = DocSpring::Client.new
puts 'Generating PDF, but not waiting for job to finish processing...'
response = docspring.generate_pdf(
template_id: TEMPLATE_ID,
wait: false,
data: {
first_name: 'John',
last_name: 'Smith',
favorite_color: 'Blue',
}
)
puts 'PDF job was submitted:'
puts response
submission = response.submission
while submission.state == 'pending'
sleep 1
submission = docspring.get_submission(response.submission.id)
end
puts 'PDF finished processing:'
puts submission
rescue DocSpring::ApiError => e
puts "#{e.class}: #{e.message}"
puts e.code # HTTP response code
puts e.response_body # HTTP response body
puts e.backtrace[0..3].join("\n")
end
|
DocSpring/openapi-generator-mirror
|
docspring-generator/target/classes/ruby-client/examples/generate_pdf.erb.rb
|
<reponame>DocSpring/openapi-generator-mirror<filename>docspring-generator/target/classes/ruby-client/examples/generate_pdf.erb.rb
client = DocSpring::Client.new
template_id = 'tpl_000000000000000001'
<% if @template_type != :doc -%>
expect(client).to receive(:sleep).with(1).once
<% end -%>
response = client.generate_pdf(
template_id: template_id,
data: {
title: 'Test PDF',
description: 'This PDF is great!',
},
field_overrides: {
title: {
required: false
}
}
)
submission = response.submission
<% if @template_type == :doc -%>
puts "Download your PDF at: #{submission.download_url}"
<% else -%>
expect(response.status).to eq 'success'
expect(submission.id).to start_with 'sub_'
expect(submission.expired).to eq false
expect(submission.state).to eq 'processed'
expect(submission.pdf_hash).to eq 'TEST_SUBMISSION_SHA256_HASH'
expect(submission.download_url).to include 'submissions/submission.pdf'
<% end -%>
|
DocSpring/openapi-generator-mirror
|
docspring-generator/target/classes/ruby-client/examples/setup_client.erb.rb
|
DocSpring.configure do |c|
c.api_token_id = 'api_token123'
c.api_token_secret = 'testsecret123'
end
|
DocSpring/openapi-generator-mirror
|
examples/ruby/generate_and_download_pdf.rb
|
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This example demonstrates generating a PDF from a preconfigured template,
# and downloading the PDF to a local file.
#
# You can run this example with: ./examples/ruby/generate_and_download_pdf.rb
Dir.chdir File.join(File.dirname(__FILE__), '../../clients/ruby')
require 'bundler/setup'
Bundler.require
# This is a real test API token and template on docspring.com
# -------------------------------------------------------------
API_TOKEN_ID = '<KEY>'
API_TOKEN_SECRET = '<KEY>'
TEMPLATE_ID = '6zz3dYRYM67fxMXA'
PDF_FILENAME = '/tmp/docspring-test.pdf'
begin
DocSpring.configure do |c|
c.username = API_TOKEN_ID # Your API Token ID
c.password = <PASSWORD>_TOKEN_SECRET # Your API Token Secret
# c.debugging = true
end
docspring = DocSpring::Client.new
puts 'Generating PDF...'
response = docspring.generate_pdf(
template_id: TEMPLATE_ID,
data: {
first_name: 'John',
last_name: 'Smith',
favorite_color: 'Blue',
}
)
puts "Downloading PDF to #{PDF_FILENAME}..."
# Note: This example uses the Typhoeus library to download the file as a stream.
# This is a good way to download files, since the whole file is not loaded into memory.
# (The docspring gem includes Typhoeus as a dependency.)
downloaded_file = File.open PDF_FILENAME, 'wb'
request = Typhoeus::Request.new(response.submission.download_url)
request.on_body { |chunk| downloaded_file.write(chunk) }
request.on_complete do |_response|
downloaded_file.close
puts 'PDF was downloaded! Opening file...'
# Open the downloaded PDF on Mac or Linux.
`type xdg-open > /dev/null 2>&1 && xdg-open '#{PDF_FILENAME}' || open '#{PDF_FILENAME}'`
end
request.run
rescue DocSpring::ApiError => e
puts "#{e.class}: #{e.message}"
puts e.code # HTTP response code
puts e.response_body # HTTP response body
puts e.backtrace[0..3].join("\n")
end
|
DocSpring/openapi-generator-mirror
|
docspring-generator/target/classes/ruby-client/examples/add_fields_to_template.erb.rb
|
<% if @template_type == :doc -%>
client = DocSpring::Client.new
<% end -%>
template_id = 'tpl_000000000000000001'
response = client.add_fields_to_template(
template_id,
fields: [
{
name: 'new_field1',
page: 1,
required: false,
},
{
name: 'new_field2',
type: 'number',
page: 1,
required: false,
},
{
name: 'new_field3',
type: 'date',
page: 1,
required: false,
x: 300,
},
]
)
<% if @template_type == :doc -%>
puts response
# => {:new_field_ids=>[3, 4, 5], :status=>"success"}
<% else -%>
expect(response.status).to eq 'success'
expect(response.new_field_ids).to eq [3, 4, 5]
expect(response.new_field_ids[0].class).to eq Integer
<% end -%>
|
DocSpring/openapi-generator-mirror
|
examples/ruby/merge_generated_pdfs.rb
|
#!/usr/bin/env ruby
# frozen_string_literal: true
#
# This example demonstrates merging multiple generated PDFs into a single PDF.
#
# This example is just a demonstration, and cannot be run from the command line.
Dir.chdir File.join(File.dirname(__FILE__), '../../clients/ruby')
require 'bundler/setup'
Bundler.require
begin
DocSpring.configure do |c|
c.username = ENV['DOCSPRING_TOKEN_ID']
c.password = ENV['DOCSPRING_TOKEN_SECRET']
end
docspring = DocSpring::Client.new
response = docspring.combine_submissions(
submission_ids: %w[SUBMISSION_1_ID SUBMISSION_2_ID],
metadata: {
user_id: 123,
}
)
puts "Download your combined PDF at: #{response.combined_submission.download_url}"
rescue DocSpring::ApiError => e
puts "#{e.class}: #{e.message}"
puts e.code # HTTP response code
puts e.response_body # HTTP response body
puts e.backtrace[0..3].join("\n")
end
|
ryanlntn/medic
|
spec/medic/source_query_builder_spec.rb
|
<reponame>ryanlntn/medic
describe Medic::SourceQueryBuilder do
before do
@subject = Medic::SourceQueryBuilder.new type: :dietary_protein do |query, sources, error|
end
end
it "has a query getter that returns an HKSourceQuery" do
@subject.query.should.be.kind_of? HKSourceQuery
end
end
|
ryanlntn/medic
|
spec/medic/statistics_options_spec.rb
|
<filename>spec/medic/statistics_options_spec.rb
describe Medic::StatisticsOptions do
before do
@subject = Object.new
@subject.extend(Medic::StatisticsOptions)
end
describe "#options_for_stat_query" do
it "correctly calculates the value for options" do
@subject.options_for_stat_query(:none).should == 0
@subject.options_for_stat_query([:by_source, :sum]).should == 17
@subject.options_for_stat_query([:average, :min, :max]).should == 14
end
end
describe "#statistics_option" do
it "returns the correct type identifier for symbol" do
@subject.statistics_option(:none).should == HKStatisticsOptionNone
@subject.statistics_option(:by_source).should == HKStatisticsOptionSeparateBySource
@subject.statistics_option(:separate_by_source).should == HKStatisticsOptionSeparateBySource
@subject.statistics_option(:average).should == HKStatisticsOptionDiscreteAverage
@subject.statistics_option(:discrete_average).should == HKStatisticsOptionDiscreteAverage
@subject.statistics_option(:min).should == HKStatisticsOptionDiscreteMin
@subject.statistics_option(:discrete_min).should == HKStatisticsOptionDiscreteMin
@subject.statistics_option(:max).should == HKStatisticsOptionDiscreteMax
@subject.statistics_option(:discrete_max).should == HKStatisticsOptionDiscreteMax
@subject.statistics_option(:sum).should == HKStatisticsOptionCumulativeSum
@subject.statistics_option(:cumulative_sum).should == HKStatisticsOptionCumulativeSum
end
end
end
|
ryanlntn/medic
|
spec/medic/types_spec.rb
|
describe Medic::Types do
before do
@subject = Object.new
@subject.extend(Medic::Types)
end
describe "#object_type" do
it "returns the correct object type for symbol" do
@subject.object_type(:step_count).should.be.kind_of? HKQuantityType
@subject.object_type(:food).should.be.kind_of? HKCorrelationType
@subject.object_type(:blood_type).should.be.kind_of? HKCharacteristicType
@subject.object_type(:sleep_analysis).should.be.kind_of? HKCategoryType
@subject.object_type(:workout).should.be.kind_of? HKWorkoutType
end
end
describe "#type_identifier" do
it "returns the correct type identifier for symbol" do
@subject.type_identifier(:body_mass_index).should == HKQuantityTypeIdentifierBodyMassIndex
@subject.type_identifier(:body_fat_percentage).should == HKQuantityTypeIdentifierBodyFatPercentage
@subject.type_identifier(:height).should == HKQuantityTypeIdentifierHeight
@subject.type_identifier(:body_mass).should == HKQuantityTypeIdentifierBodyMass
@subject.type_identifier(:lean_body_mass).should == HKQuantityTypeIdentifierLeanBodyMass
@subject.type_identifier(:step_count).should == HKQuantityTypeIdentifierStepCount
@subject.type_identifier(:distance_walking_running).should == HKQuantityTypeIdentifierDistanceWalkingRunning
@subject.type_identifier(:distance_cycling).should == HKQuantityTypeIdentifierDistanceCycling
@subject.type_identifier(:basal_energy_burned).should == HKQuantityTypeIdentifierBasalEnergyBurned
@subject.type_identifier(:active_energy_burned).should == HKQuantityTypeIdentifierActiveEnergyBurned
@subject.type_identifier(:flights_climbed).should == HKQuantityTypeIdentifierFlightsClimbed
@subject.type_identifier(:nike_fuel).should == HKQuantityTypeIdentifierNikeFuel
@subject.type_identifier(:heart_rate).should == HKQuantityTypeIdentifierHeartRate
@subject.type_identifier(:body_temperature).should == HKQuantityTypeIdentifierBodyTemperature
@subject.type_identifier(:blood_pressure_systolic).should == HKQuantityTypeIdentifierBloodPressureSystolic
@subject.type_identifier(:blood_pressure_diastolic).should == HKQuantityTypeIdentifierBloodPressureDiastolic
@subject.type_identifier(:respiratory_rate).should == HKQuantityTypeIdentifierRespiratoryRate
@subject.type_identifier(:oxygen_saturation).should == HKQuantityTypeIdentifierOxygenSaturation
@subject.type_identifier(:peripheral_perfusion_index).should == HKQuantityTypeIdentifierPeripheralPerfusionIndex
@subject.type_identifier(:blood_glucose).should == HKQuantityTypeIdentifierBloodGlucose
@subject.type_identifier(:number_of_times_fallen).should == HKQuantityTypeIdentifierNumberOfTimesFallen
@subject.type_identifier(:electrodermal_activity).should == HKQuantityTypeIdentifierElectrodermalActivity
@subject.type_identifier(:inhaler_usage).should == HKQuantityTypeIdentifierInhalerUsage
@subject.type_identifier(:blood_alcohol_content).should == HKQuantityTypeIdentifierBloodAlcoholContent
@subject.type_identifier(:forced_vital_capacity).should == HKQuantityTypeIdentifierForcedVitalCapacity
@subject.type_identifier(:forced_expiratory_volume1).should == HKQuantityTypeIdentifierForcedExpiratoryVolume1
@subject.type_identifier(:peak_expiratory_flow_rate).should == HKQuantityTypeIdentifierPeakExpiratoryFlowRate
@subject.type_identifier(:dietary_biotin).should == HKQuantityTypeIdentifierDietaryBiotin
@subject.type_identifier(:dietary_caffeine).should == HKQuantityTypeIdentifierDietaryCaffeine
@subject.type_identifier(:dietary_calcium).should == HKQuantityTypeIdentifierDietaryCalcium
@subject.type_identifier(:dietary_carbohydrates).should == HKQuantityTypeIdentifierDietaryCarbohydrates
@subject.type_identifier(:dietary_chloride).should == HKQuantityTypeIdentifierDietaryChloride
@subject.type_identifier(:dietary_cholesterol).should == HKQuantityTypeIdentifierDietaryCholesterol
@subject.type_identifier(:dietary_chromium).should == HKQuantityTypeIdentifierDietaryChromium
@subject.type_identifier(:dietary_copper).should == HKQuantityTypeIdentifierDietaryCopper
@subject.type_identifier(:dietary_energy_consumed).should == HKQuantityTypeIdentifierDietaryEnergyConsumed
@subject.type_identifier(:dietary_fat_monounsaturated).should == HKQuantityTypeIdentifierDietaryFatMonounsaturated
@subject.type_identifier(:dietary_fat_polyunsaturated).should == HKQuantityTypeIdentifierDietaryFatPolyunsaturated
@subject.type_identifier(:dietary_fat_saturated).should == HKQuantityTypeIdentifierDietaryFatSaturated
@subject.type_identifier(:dietary_fat_total).should == HKQuantityTypeIdentifierDietaryFatTotal
@subject.type_identifier(:dietary_fiber).should == HKQuantityTypeIdentifierDietaryFiber
@subject.type_identifier(:dietary_folate).should == HKQuantityTypeIdentifierDietaryFolate
@subject.type_identifier(:dietary_iodine).should == HKQuantityTypeIdentifierDietaryIodine
@subject.type_identifier(:dietary_iron).should == HKQuantityTypeIdentifierDietaryIron
@subject.type_identifier(:dietary_magnesium).should == HKQuantityTypeIdentifierDietaryMagnesium
@subject.type_identifier(:dietary_manganese).should == HKQuantityTypeIdentifierDietaryManganese
@subject.type_identifier(:dietary_molybdenum).should == HKQuantityTypeIdentifierDietaryMolybdenum
@subject.type_identifier(:dietary_niacin).should == HKQuantityTypeIdentifierDietaryNiacin
@subject.type_identifier(:dietary_pantothenic_acid).should == HKQuantityTypeIdentifierDietaryPantothenicAcid
@subject.type_identifier(:dietary_phosphorus).should == HKQuantityTypeIdentifierDietaryPhosphorus
@subject.type_identifier(:dietary_potassium).should == HKQuantityTypeIdentifierDietaryPotassium
@subject.type_identifier(:dietary_protein).should == HKQuantityTypeIdentifierDietaryProtein
@subject.type_identifier(:dietary_riboflavin).should == HKQuantityTypeIdentifierDietaryRiboflavin
@subject.type_identifier(:dietary_selenium).should == HKQuantityTypeIdentifierDietarySelenium
@subject.type_identifier(:dietary_sodium).should == HKQuantityTypeIdentifierDietarySodium
@subject.type_identifier(:dietary_sugar).should == HKQuantityTypeIdentifierDietarySugar
@subject.type_identifier(:dietary_thiamin).should == HKQuantityTypeIdentifierDietaryThiamin
@subject.type_identifier(:dietary_vitamin_a).should == HKQuantityTypeIdentifierDietaryVitaminA
@subject.type_identifier(:dietary_vitamin_b12).should == HKQuantityTypeIdentifierDietaryVitaminB12
@subject.type_identifier(:dietary_vitamin_b6).should == HKQuantityTypeIdentifierDietaryVitaminB6
@subject.type_identifier(:dietary_vitamin_c).should == HKQuantityTypeIdentifierDietaryVitaminC
@subject.type_identifier(:dietary_vitamin_d).should == HKQuantityTypeIdentifierDietaryVitaminD
@subject.type_identifier(:dietary_vitamin_e).should == HKQuantityTypeIdentifierDietaryVitaminE
@subject.type_identifier(:dietary_vitamin_k).should == HKQuantityTypeIdentifierDietaryVitaminK
@subject.type_identifier(:dietary_zinc).should == HKQuantityTypeIdentifierDietaryZinc
@subject.type_identifier(:sleep_analysis).should == HKCategoryTypeIdentifierSleepAnalysis
@subject.type_identifier(:biological_sex).should == HKCharacteristicTypeIdentifierBiologicalSex
@subject.type_identifier(:blood_type).should == HKCharacteristicTypeIdentifierBloodType
@subject.type_identifier(:date_of_birth).should == HKCharacteristicTypeIdentifierDateOfBirth
@subject.type_identifier(:blood_pressure).should == HKCorrelationTypeIdentifierBloodPressure
@subject.type_identifier(:food).should == HKCorrelationTypeIdentifierFood
@subject.type_identifier(:workout).should == HKWorkoutTypeIdentifier
end
end
end
|
ryanlntn/medic
|
spec/medic/predicate_spec.rb
|
describe Medic::Predicate do
before do
@subject = Object.new
@subject.extend(Medic::Predicate)
end
describe "#predicate" do
it "returns an NSPredicate for the given symbols" do
@subject.predicate(uuid: :something).should.be.kind_of NSPredicate
@subject.predicate(source: :something).should.be.kind_of NSPredicate
@subject.predicate(meta_data: :something).should.be.kind_of NSPredicate
@subject.predicate(no_correlation: true).should.be.kind_of NSPredicate
@subject.predicate(workout: :something).should.be.kind_of NSPredicate
end
it "passes through the NSPredicate if given a predicate" do
@subject.predicate(predicate: :whatever).should == :whatever
end
it "returns nil if no arguments match" do
@subject.predicate({}).should == nil
@subject.predicate({nonsense: nil}).should == nil
end
end
end
|
ryanlntn/medic
|
app/controllers/save_controller.rb
|
<gh_stars>10-100
class SaveController < BaseController
def viewDidLoad
super
self.view.backgroundColor = UIColor.purpleColor
self.title = "Save"
end
def viewDidAppear(animated)
blood_pressure = {
correlation_type: :blood_pressure,
objects: [
{
quantity_type: :blood_pressure_systolic,
quantity: 120
},
{
quantity_type: :blood_pressure_diastolic,
quantity: 80
}
]
}
Medic.save(blood_pressure) do |success, error|
NSLog "Saved sample" unless error
end
end
end
|
ryanlntn/medic
|
spec/medic/statistics_collection_query_builder_spec.rb
|
describe Medic::StatisticsCollectionQueryBuilder do
before do
query_params = { type: :step_count, options: :sum, interval: :day }
@subject = Medic::StatisticsCollectionQueryBuilder.new query_params do |query, collection, error|
@block_contents = [query, collection, error]
end
query_params2 = { type: :step_count, options: :sum, interval: :day, update: true }
@subject_with_update = Medic::StatisticsCollectionQueryBuilder.new query_params2 do |query, collection, error|
@block_contents = [query, collection, error]
end
end
after do
@block_contents = nil
end
it "has a query getter that returns an HKStatisticsCollectionQuery" do
@subject.query.should.be.kind_of? HKStatisticsCollectionQuery
end
describe "initialize" do
it "sets initialResultsHandler when given block" do
@subject.query.initialResultsHandler.call(:query, :collection, :error)
@block_contents.should == [:query, :collection, :error]
end
context "when :update is given" do
it "sets statisticsUpdateHandler when given block" do
@subject_with_update.query.statisticsUpdateHandler.call(:query, :statistics, :collection, :error)
@block_contents.should == [:query, :collection, :error]
end
end
context "when :update isn't given" do
it "doesn't set statisticsUpdateHandler when given block" do
@subject.query.statisticsUpdateHandler.should == nil
@block_contents.should == nil
end
end
end
describe "#initial_results_handler=" do
it "sets initialResultsHandler with callback" do
@subject.query.initialResultsHandler.should.respond_to? :call
end
end
describe "#statistics_update_handler=" do
it "sets statisticsUpdateHandler with callback" do
@subject_with_update.query.statisticsUpdateHandler.should.respond_to? :call
end
end
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.