repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
ack43/rocket_cms | lib/rocket_cms/patch.rb | module RocketCMS
class PatchDSL
def self.call(&blk)
instance = new
instance.instance_eval(&blk)
instance.instance_variables.inject({}) { |result_hash, instance_variable|
result_hash[instance_variable[1..-1].to_sym] = instance.instance_variable_get(instance_variable)
result_hash
... |
ack43/rocket_cms | lib/rocket_cms/models/mongoid/menu.rb | <reponame>ack43/rocket_cms
module RocketCMS
module Models
module Mongoid
module Menu
extend ActiveSupport::Concern
included do
field :name, type: String, default: ""
end
end
end
end
end
|
ack43/rocket_cms | app/models/gallery_image.rb | if RocketCMS.mongoid?
class GalleryImage
include RocketCMS::Models::GalleryImage
RocketCMS.apply_patches self
rails_admin &RocketCMS.image_config
end
end |
ack43/rocket_cms | lib/rocket_cms/models/active_record/menu.rb | module RocketCMS
module Models
module ActiveRecord
module Menu
extend ActiveSupport::Concern
included do
has_paper_trail
validates_lengths_from_database
if RocketCMS.config.localize
translates :name
end
end
end
end
end
e... |
ack43/rocket_cms | app/models/concerns/geocodeable.rb | module Geocodeable
extend ActiveSupport::Concern
include Mappable
end
|
ack43/rocket_cms | lib/rocket_cms/controllers/search.rb | module RocketCMS
module Controllers
module Search
extend ActiveSupport::Concern
# def index
# if params[:query].blank?
# @results = []
# else
# @results = Mongoid::Elasticsearch.search({
# body: {
# query: {
# query_string: ... |
ack43/rocket_cms | app/models/concerns/enableable.rb | module Enableable
extend ActiveSupport::Concern
include BooleanField
included do
boolean_field(:enabled)
end
end
|
ack43/rocket_cms | lib/rocket_cms/models/mongoid/news.rb | module RocketCMS
module Models
module Mongoid
module News
extend ActiveSupport::Concern
unless RocketCMS.config.news_image_styles.nil?
include ::Mongoid::Paperclip
end
included do
field :time, type: Time
index({enabled: 1, time: 1})
unl... |
ack43/rocket_cms | mongoid/rocket_cms_mongoid.gemspec | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
lib = File.expand_path('../../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rocket_cms/version'
Gem::Specification.new do |spec|
spec.name = 'ack_rocket_cms_mongoid'
spec... |
ack43/rocket_cms | activerecord/lib/rocket_cms_activerecord.rb | <filename>activerecord/lib/rocket_cms_activerecord.rb
require 'awesome_nested_set'
require 'paperclip'
require 'paper_trail'
require 'friendly_id'
require 'validates_lengths_from_database'
require 'pg_search'
module RocketCMS
def self.orm
:active_record
end
end
require 'rocket_cms' |
ack43/rocket_cms | app/models/news.rb | if RocketCMS.active_record?
class News < ActiveRecord::Base
end
end
class News
include RocketCMS::Models::News
RocketCMS.apply_patches self
rails_admin &RocketCMS.news_config
end
|
ack43/rocket_cms | template.rb | rails_spec = (Gem.loaded_specs["railties"] || Gem.loaded_specs["rails"])
version = rails_spec.version.to_s
mongoid = options[:skip_active_record]
if Gem::Version.new(version) < Gem::Version.new('4.2.4')
puts "You are using an old version of Rails (#{version})"
puts "Please update"
puts "Stopping"
exit 1
end
... |
ack43/rocket_cms | app/models/contact_message.rb | if RocketCMS.active_record?
class ContactMessage < ActiveRecord::Base
end
end
class ContactMessage
include RocketCMS::Models::ContactMessage
RocketCMS.apply_patches self
rails_admin &RocketCMS.contact_message_config
end
|
ack43/rocket_cms | lib/rocket_cms/models/mongoid/page.rb | module RocketCMS
module Models
module Mongoid
module Page
extend ActiveSupport::Concern
included do
field :regexp, type: String, default: ""
field :redirect, type: String, default: ""
field :excerpt, type: String, localize: RocketCMS.config.localize, default: ""... |
ack43/rocket_cms | lib/rocket_cms/migration.rb | <gh_stars>0
module RocketCMS
module Migration
extend self
def seo_fields(t)
if RocketCMS.config.localize
t.column :h1_translations, 'hstore', default: {}
t.column :title_translations, 'hstore', default: {}
t.column :keywords_translations, 'hstore', default: {}
t.column :... |
ack43/rocket_cms | app/models/seo.rb | if RocketCMS.active_record?
class Seo < ActiveRecord::Base
end
end
class Seo
include RocketCMS::Models::Seo
RocketCMS.apply_patches self
rails_admin &RocketCMS.seo_config
belongs_to :seoable, polymorphic: true
def self.separate_table?
(RocketCMS.mongoid? && RocketCMS.config.separate_seo_table) || (R... |
ack43/rocket_cms | app/controllers/news_controller.rb | <gh_stars>10-100
class NewsController < ApplicationController
include RocketCMS::Controllers::News
end
|
ack43/rocket_cms | app/models/page.rb | if RocketCMS.active_record?
class Page < ActiveRecord::Base
end
end
class Page
include RocketCMS::Models::Page
RocketCMS.apply_patches self
rails_admin &RocketCMS.page_config
end
|
ack43/rocket_cms | lib/rocket_cms/models/embedded_gallery_image.rb | <gh_stars>0
module RocketCMS
module Models
module EmbeddedGalleryImage
extend ActiveSupport::Concern
include RocketCMS::Model
include Enableable
include Sortable
include RocketCMS.orm_specific('EmbeddedGalleryImage')
included do
validates_attachment_content_type :image... |
ack43/rocket_cms | app/mailers/contact_mailer.rb | <reponame>ack43/rocket_cms<gh_stars>0
class ContactMailer < ActionMailer::Base
def new_message_email(message)
@message = message
#if message.attachment?
# attachments[message.attachment.identifier] = File.read(message.attachment.current_path)
#end
mail(
from: Settings.default_email_from... |
ack43/rocket_cms | lib/rocket_cms/admin.rb | module RocketCMS
class << self
def map_config(is_active = true)
Proc.new {
active is_active
label I18n.t('rs.map')
field :address, :string
field :map_address, :string
field :map_hint, :string
field :coordinates, :string do
read_only true
fo... |
ack43/rocket_cms | lib/generators/rocket_cms/templates/migration_news.rb | <reponame>ack43/rocket_cms<filename>lib/generators/rocket_cms/templates/migration_news.rb
class RocketCmsCreateNews < ActiveRecord::Migration
def change
create_table :news do |t|
t.boolean :enabled, default: true, null: false
t.timestamp :time, null: false
if RocketCMS.config.localize
t... |
ack43/rocket_cms | app/controllers/contacts_controller.rb | class ContactsController < ApplicationController
include RocketCMS::Controllers::Contacts
end
|
ack43/rocket_cms | lib/rocket_cms/models/page.rb | module RocketCMS
module Models
module Page
extend ActiveSupport::Concern
include RocketCMS::Model
include Enableable
include Seoable
include ManualSlug
include SitemapData
include RocketCMS.orm_specific('Page')
if RocketCMS.config.search_enabled
include Ro... |
ack43/rocket_cms | app/models/concerns/sitemap_data.rb | <reponame>ack43/rocket_cms
module SitemapData
extend ActiveSupport::Concern
SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
included do
if RocketCMS.mongoid?
field :sitemap_show, type: Boolean, default: true
field :sitemap_lastmod, type: DateTime
f... |
ack43/rocket_cms | app/models/concerns/seoable.rb | module Seoable
extend ActiveSupport::Concern
LOCALIZED_FIELDS = [:h1, :title, :keywords, :description, :og_title]
FIELDS = LOCALIZED_FIELDS + [:og_image, :robots]
if Seo.separate_table?
included do
has_one :seo, as: :seoable, autosave: true
accepts_nested_attributes_for :seo
delegate *FIE... |
ack43/rocket_cms | lib/rocket_cms/controllers/pages.rb | <filename>lib/rocket_cms/controllers/pages.rb
module RocketCMS
module Controllers
module Pages
extend ActiveSupport::Concern
def show
if @seo_page.nil? || !@seo_page.persisted?
if !params[:id].blank? or !params[:slug].blank?
@seo_page = Page.enabled.find(params[:id] || pa... |
ack43/rocket_cms | lib/generators/rocket_cms/templates/migration_pages.rb | <filename>lib/generators/rocket_cms/templates/migration_pages.rb
class RocketCmsCreatePages < ActiveRecord::Migration
def change
create_table :menus do |t|
if RocketCMS.config.localize
t.column :name_translations, 'hstore'
else
t.string :name, null: false
end
t.string :slu... |
ack43/rocket_cms | rocket_cms.gemspec | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'rocket_cms/version'
Gem::Specification.new do |spec|
spec.name = 'ack_rocket_cms'
spec.version = RocketCMS::VERSION
spec.authors = ['<NAME>', 'glebtv']
spec.email = ["<EMAIL>... |
ack43/rocket_cms | lib/rocket_cms/models/embedded_element.rb | <filename>lib/rocket_cms/models/embedded_element.rb
module RocketCMS
module Models
module EmbeddedElement
extend ActiveSupport::Concern
include RocketCMS::Model
include Enableable
include Sortable
include RocketCMS.orm_specific('EmbeddedElement')
end
end
end |
ack43/rocket_cms | lib/rocket_cms/models/seo.rb | <reponame>ack43/rocket_cms
module RocketCMS
module Models
module Seo
extend ActiveSupport::Concern
include RocketCMS::Model
include Enableable
include RocketCMS.orm_specific('Seo')
include RocketCMS::SeoHelpers
included do
RocketCMS.apply_patches self
validates... |
ack43/rocket_cms | app/models/concerns/sortable.rb | <filename>app/models/concerns/sortable.rb
module Sortable
extend ActiveSupport::Concern
include SortField
included do
sort_field
end
end
|
vifreefly/sequel-db_tasks | test/sequel/db_tasks_test.rb | <filename>test/sequel/db_tasks_test.rb
require "test_helper"
class Sequel::DbTasksTest < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Sequel::DbTasks::VERSION
end
def test_it_does_something_useful
assert false
end
end
|
vifreefly/sequel-db_tasks | lib/sequel/db_tasks/tasks.rake | <gh_stars>1-10
# All possible rails db tasks https://jacopretorius.net/2014/02/all-rails-db-rake-tasks-and-what-they-do.html
namespace :db do
task :preload, [:skip_adapter_validation] do |t, args|
require 'uri'
@url = Sequel::DbTasks.configuration.database_url
uri = URI.parse(@url)
unless args[:ski... |
vifreefly/sequel-db_tasks | lib/sequel/db_tasks.rb | <filename>lib/sequel/db_tasks.rb
require 'ostruct'
module Sequel
module DbTasks
def self.configuration
@configuration ||= OpenStruct.new(
database_url: ENV["DATABASE_URL"],
migrations_path: "db/migrate"
)
end
def self.configure
yield(configuration)
end
def self... |
JubalThang/twitter_many_to_many | lib/twitter_many_to_many/like.rb | class Like
@@all = []
def self.all
@@all
end
def initialize(attributes = {})
@tweet = attributes[:tweet]
@user = attributes[:user]
@@all << self
end
end |
JubalThang/twitter_many_to_many | spec/01_examples_spec.rb | <reponame>JubalThang/twitter_many_to_many
# We can build more complicated relationships using one to many more than once.
RSpec.describe "Aquarium domain" do
let(:aquarium) { Aquarium.new(name: "Aquarium of the Pacific")}
let(:coral_reefs_exhibit) { Exhibit.new(name: "Coral Reefs: Nature's Underwater Cities", aqu... |
JubalThang/twitter_many_to_many | spec/02_exercise_spec.rb | <gh_stars>0
RSpec.describe "Exercise - Many to Many - User <=> Tweet through likes" do
let(:user1) { User.new(username: "Dakota") }
let(:user2) { User.new(username: "Sandra") }
let(:tweet1) { Tweet.new(message: "I can show you the world", user: user1)}
let(:tweet2) { Tweet.new(message: "Shining, shimmering, s... |
JubalThang/twitter_many_to_many | lib/twitter_many_to_many.rb | require "pry"
require "twitter_many_to_many/version"
require "twitter_many_to_many/examples"
require "twitter_many_to_many/like"
require "twitter_many_to_many/user"
require "twitter_many_to_many/tweet"
module TwitterManyToMany
class Error < StandardError; end
# Your code goes here...
end
|
JubalThang/twitter_many_to_many | lib/twitter_many_to_many/tweet.rb | class Tweet
@@all = []
def self.all
@@all
end
attr_reader :message, :user
def initialize(attributes = {})
@message = attributes[:message]
@user = attributes[:user]
@@all << self
end
def username
user.username
end
def delete
Tweet.all.delete(self)
end
end |
zachalbert/wbc | extras/rails/config/initializers/blendid.rb | <reponame>zachalbert/wbc
ASSET_PATH_CONFIG = JSON.parse(File.read('config/path-config.json'))
REV_MANIFEST_PATH = File.join(ASSET_PATH_CONFIG['dest'].gsub("..", "."), 'rev-manifest.json')
if File.exist?(REV_MANIFEST_PATH)
REV_MANIFEST = JSON.parse(File.read(REV_MANIFEST_PATH))
elsif !Rails.env.development? && !Rails... |
heroku/identity | lib/identity/heroku_cookie.rb | <gh_stars>10-100
module Identity
# This extension helps with set/unset logic for the infamous Heroku cookie
# used by Identity and other Heroku properties. The purpose of the Heroku
# cookie is to set a general cookie available on the `.heroku.com` domain
# that helps signal to other properties that the current... |
heroku/identity | test/service_stubs/heroku_api_stub.rb | require "multi_json"
require "sinatra/base"
require "sinatra/namespace"
class HerokuAPIStub < Sinatra::Base
AUTHORIZATION = {
client: {
redirect_uri: "https://dashboard.heroku.com/oauth/callback/heroku"
},
grant: { code: "454118bc-902d-4a2c-9d5b-e2a2abb91f6e" }
}
register Sinatra::Namespace
... |
heroku/identity | test/robots_test.rb | <filename>test/robots_test.rb
require_relative "test_helper"
describe Identity::Robots do
include Rack::Test::Methods
def app
Identity::Robots
end
describe "GET /robots.txt" do
it "responds with a robots file" do
get "/robots.txt"
assert_match /text\/plain/, last_response.headers["Content... |
heroku/identity | test/error_handling_test.rb | <gh_stars>10-100
require_relative "test_helper"
describe Identity::ErrorHandling do
include Rack::Test::Methods
def app
Sinatra.new do
register Identity::ErrorHandling
set :views, "#{Identity::Config.root}/views"
get "/401" do
raise Excon::Errors::Unauthorized.new("go away")
... |
heroku/identity | test/login_external_test.rb | require_relative "test_helper"
describe Identity::Account do
include Rack::Test::Methods
def app
Rack::Builder.new do
use Rack::Session::Cookie, domain: "example.org", secret: "my-secret"
run Identity::LoginExternal
end
end
def request_session
last_request.env["rack.session"]
end
... |
heroku/identity | lib/identity/heroku_api.rb | <reponame>heroku/identity<filename>lib/identity/heroku_api.rb
require "base64"
module Identity
class HerokuAPI < Excon::Connection
def initialize(ip:, version:, authorization: nil, headers: {}, pass: nil,
request_ids: [], user: nil)
headers = {
"Accept" => "application/vnd.heroku+jso... |
heroku/identity | lib/identity/config.rb | module Identity
module Config
extend self
def cookie_encryption_key
ENV.fetch("COOKIE_ENCRYPTION_KEY")
end
def old_cookie_encryption_key
ENV["OLD_COOKIE_ENCRYPTION_KEY"]
end
def heroku_root_domain_cookie_encryption_key
ENV.fetch("HEROKU_ROOT_DOMAIN_COOKIE_ENCRYPTION_KEY")
... |
heroku/identity | lib/identity.rb | require_relative "identity/config"
require_relative "identity/csrf"
require_relative "identity/cookie"
require_relative "identity/design"
require_relative "identity/error_handling"
require_relative "identity/errors"
require_relative "identity/excon_instrumentor"
require_relative "identity/fernet_cookie_coder"
require_r... |
heroku/identity | test/auth_test.rb | <filename>test/auth_test.rb
require_relative "test_helper"
describe Identity::Auth do
include Rack::Test::Methods
def app
Rack::Builder.new do
use Rack::Session::Cookie, domain: "example.org", secret: "my-secret"
use Rack::Flash
run Identity::Auth
end
end
before do
stub_heroku_a... |
heroku/identity | lib/identity/auth.rb | module Identity
class Auth < Sinatra::Base
register ErrorHandling
register HerokuCookie
register Sinatra::Namespace
include Helpers::API
include Helpers::Auth
include Helpers::Log
configure do
set :views, "#{Config.root}/views"
end
before do
@cookie = Cookie.new(env[... |
heroku/identity | lib/identity/helpers/api.rb | <filename>lib/identity/helpers/api.rb<gh_stars>10-100
module Identity::Helpers
module API
def decode_error(body)
json = MultiJson.decode(body)
if json.is_a?(Hash)
# use the message field, otherwise munge the errors together
json["message"] || json.map { |e| e.join(" ") }.join("; ")
... |
heroku/identity | test/helpers/api_test.rb | require_relative "../test_helper"
describe Identity::Helpers::API do
include Identity::Helpers::API
describe :decode_error do
before do
stub(self).log
end
it "returns the message value for v3 error messages" do
error = {
id: "rate_limit",
message: "Please wait a few m... |
heroku/identity | test/service_stubs.rb | require_relative "service_stubs/heroku_api_stub"
def stub_service(uri, stub, &block)
uri = URI.parse(uri)
port = uri.port != uri.default_port ? ":#{uri.port}" : ""
stub = block ? Sinatra.new(stub, &block) : stub
stub_request(:any, /^#{uri.scheme}:\/\/(.*:.*@)?#{uri.host}#{port}\/.*$/).
to_rack(stub)
end
d... |
heroku/identity | test/account_test.rb | require_relative "test_helper"
describe Identity::Account do
include Rack::Test::Methods
def app
Rack::Builder.new do
use Rack::Session::Cookie, secret: "my-secret"
use Rack::Flash
run Identity::Account
end
end
before do
stub_heroku_api
rack_mock_session.clear_cookies
end
... |
heroku/identity | lib/identity/fernet_cookie_coder.rb | require "base64"
require "rack/session/cookie"
module Identity
class FernetCookieCoder
def initialize(*keys)
@keys = keys.compact
end
def encode(raw)
# use Marshal instead of JSON to avoid trouble with string/symbol
# conversions
data = Base64.urlsafe_encode64(Marshal.dump(raw))
... |
heroku/identity | lib/identity/rescue_errors.rb | <reponame>heroku/identity
module Identity
class RescueErrors
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
rescue Exception => e
Identity.log(:exception, class: e.class.name, message: e.message,
backtrace: e.backtrace.inspect)
[500, { 'Content-Type' =... |
heroku/identity | test/csrf_test.rb | <reponame>heroku/identity
require_relative "test_helper"
describe Identity::CSRF do
include Rack::Test::Methods
def app
Sinatra.new do
use Rack::Session::Cookie, domain: "example.org", secret: "my-secret"
use Identity::CSRF
get "/good" do
200
end
get "/bad" do
r... |
heroku/identity | lib/identity/account.rb | require "addressable/uri"
require 'cgi'
module Identity
class Account < Sinatra::Base
register ErrorHandling
register HerokuCookie
register Sinatra::Namespace
include Helpers::API
include Helpers::Auth
include Helpers::Log
configure do
set :views, "#{Config.root}/views"
end
... |
heroku/identity | config.ru | <gh_stars>10-100
$stdout.sync = $stderr.sync = true
require "bundler/setup"
Bundler.require
require "./lib/identity"
#
# initialization/configuration
#
Rollbar.configure do |config|
config.disable_monkey_patch = true
config.access_token = Identity::Config.rollbar_access_token
config.enabled ... |
heroku/identity | lib/identity/robots.rb | module Identity
class Robots < Sinatra::Base
register ErrorHandling
get "/robots.txt" do
content_type :text
<<-eos
# Won't actually prevent these folders from appearing in a search engine's
# index, but isn't really harmful either.
User-agent: *
Disallow: /account/email/confirm/
Disallow: /accoun... |
heroku/identity | test/identity_assertions.rb | <gh_stars>10-100
def assert_response_redirects_with_oauth_callback(state: nil)
assert_equal 302, last_response.status
base = HerokuAPIStub::AUTHORIZATION[:client][:redirect_uri]
code = HerokuAPIStub::AUTHORIZATION[:grant][:code]
state = !state.nil? ? "&state=#{state}" : ""
assert_equal "#{base}?code=#{code}#{... |
heroku/identity | lib/identity/default.rb | <reponame>heroku/identity<gh_stars>10-100
module Identity
class Default < Sinatra::Base
register ErrorHandling
register HerokuCookie
configure do
set :views, "#{Config.root}/views"
end
before do
@cookie = Cookie.new(env["rack.session"])
end
get "/" do
if @cookie.access... |
heroku/identity | lib/identity/login_external.rb | # This defines an endpoint for external services such as Fido (Federated
# Identity) and signup.heroku.com so that they can use their own method for
# authentication and set cookies in identity.
# The endpoint is protected by a shared secret.
module Identity
class LoginExternal < Default
register Sinatra::Namespa... |
heroku/identity | lib/identity/errors.rb | <reponame>heroku/identity
module Identity::Errors
class LoginRequired < StandardError; end
class PasswordExpired < StandardError
attr_accessor :message
def initialize(_)
# Override this message so that the user doesn't see a URL that they're
# supposed to visit. Instead, just take them directl... |
heroku/identity | lib/identity/design.rb | <filename>lib/identity/design.rb
# To test a new design layout called `foo`:
# - add a view in `views/layouts/foo.slim`
# - replicate the design links adding `?layout=foo`
module Identity
class Design < Sinatra::Base
register Sinatra::Namespace
configure do
set :views, "#{Config.root}/views"
end
... |
heroku/identity | lib/identity/main.rb | module Identity
Main = Rack::Builder.new do
use Identity::RescueErrors
use Rack::Instruments,
context: { app: "identity" },
response_request_id: true
use Rack::SSL if Config.production?
use Rack::Deflater
# General cookie storing information of the logged in user; don't set the
# ... |
heroku/identity | lib/identity/helpers/auth.rb | <reponame>heroku/identity
module Identity::Helpers
module Auth
include Log
include API
# Performs the authorization step of the OAuth dance against the Heroku
# API.
def authorize(params, confirm=false)
api = Identity::HerokuAPI.new(
pass: <PASSWORD>,
ip: request.ip,
... |
heroku/identity | test/heroku_cookie_test.rb | require_relative "test_helper"
describe Identity::HerokuCookie do
include Rack::Test::Methods
def app
@app
end
it "sets the Heroku cookie when appropriate" do
@app = new_app({ "oauth_session_id" => "1234" })
get "/"
assert_includes response_cookie, "heroku_session=1; domain=.heroku.com; path=... |
heroku/identity | lib/identity/helpers/log.rb | module Identity::Helpers
module Log
def log(action, data={}, &block)
data.merge! app: "identity", request_id: request_ids
# A UUID in a shared cookie allows correlating OAuth logs with other Heroku properties
data.merge! oauth_dance_id: @oauth_dance_id if @oauth_dance_id
Slides.log(actio... |
heroku/identity | test/test_helper.rb | # seed the environment
ENV["COOKIE_ENCRYPTION_KEY"] = \
"<KEY>
ENV["HEROKU_ROOT_DOMAIN_COOKIE_ENCRYPTION_KEY"] = \
"<KEY>
ENV["DASHBOARD_URL"] = "https://dashboard.heroku.com"
ENV["SSO_BASE_URL"] = "https://sso.heroku.com"
ENV["HEROKU_API_URL"] = "https://api.heroku.com"
ENV["HEROKU_OAUTH_ID... |
heroku/identity | lib/identity/cookie.rb | module Identity
class Cookie
def initialize(session)
@session = session
self.created_at ||= Time.now
end
def access_token
@session["access_token"]
end
def access_token=(token)
@session["access_token"] = token
end
def access_token_expires_at
@session["acces... |
heroku/identity | lib/identity/csrf.rb | module Identity
class CSRF < ::Rack::Csrf
def initialize(app, opts={})
opts.merge!(raise: true)
super(app, opts)
end
def call(env)
super(env)
rescue InvalidCsrfToken
req = Rack::Request.new(env)
Identity.log :invalid_csrf_token,
actual_token: req.params['_csrf'],... |
heroku/identity | lib/identity/assets.rb | <filename>lib/identity/assets.rb
module Identity
class Assets < Sinatra::Base
register ErrorHandling
def initialize(*args)
super
path = "#{Config.root}/assets"
@assets = Sprockets::Environment.new do |env|
Identity.log :assets, path: path
env.append_path(path + "/fonts")
... |
heroku/identity | test/fernet_cookie_coder_test.rb | <gh_stars>10-100
require_relative "test_helper"
describe Identity::FernetCookieCoder do
secret = "<KEY>
another_secret = "<KEY>
it "encrypts a cookie, then decrypts a cookie" do
data = { access_token: "5<PASSWORD>" }
coder = Identity::FernetCookieCoder.new(secret)
cipher = coder.encode(data)
ass... |
heroku/identity | test/cookie_coder_test.rb | require_relative "test_helper"
describe Identity::CookieCoder do
secret = "<KEY>
another_secret = "<KEY>
it "encryptes a cookie, then descrypts a cookie" do
data = {
user: {
id: "1234",
email: "<EMAIL>",
full_name: "<NAME>"
}
}
coder = Identity::CookieCoder.new(se... |
heroku/identity | lib/identity/excon_instrumentor.rb | module Identity
class ExconInstrumentor
attr_accessor :events
def initialize(extra_data={})
@extra_data = extra_data
end
def instrument(name, params={}, &block)
data = {
app: "identity",
host: params[:host],
path: params[:path],
method: params[:... |
heroku/identity | lib/identity/error_handling.rb | <filename>lib/identity/error_handling.rb
module Identity
module ErrorHandling
UNAVAILABLE_ERRORS = [
Excon::Errors::ServerError,
# a NotAcceptable probably means that the ELB has lost its backends and
# doesn't know how to respond to our V3 "Accept"; display unavailable
Excon::Errors::NotA... |
heroku/identity | lib/identity/cookie_coder.rb | require "base64"
module Identity
# CookieCoder encodes and decodes payload before setting it to cookie
# Different from FernetCookieCoder, it doesn't use Ruby Marshal.
# The encrypted cookie is meant to consumed by other programming
# languages other than Ruby.
class CookieCoder
def initialize(*keys)
... |
heroku/identity | test/cookie_test.rb | <filename>test/cookie_test.rb
require_relative "test_helper"
describe Identity::Cookie do
it "sets created_at on initialization" do
Timecop.freeze(Time.now) do
fake_session = {}
cookie = Identity::Cookie.new(fake_session)
assert_equal Time.now.to_i, cookie.created_at.to_i
assert_equal Tim... |
martinstannard/ruby-processing | lib/ruby-processing/runner.rb | <filename>lib/ruby-processing/runner.rb
require 'ostruct'
require 'fileutils'
module Processing
# Utility class to handle the different commands that the 'rp5' command
# offers. Able to run, watch, live, create, app, applet, and unpack
class Runner
HELP_MESSAGE = <<-EOS
Ruby-Processing is a ... |
martinstannard/ruby-processing | lib/ruby-processing/runners/run.rb | <gh_stars>1-10
# Windows apps start life in the wrong folder.
ARGV[1] = nil and Dir.chdir('lib') if ARGV[1] == '--windows-app'
require "#{File.dirname(__FILE__)}/base.rb"
require Processing::SKETCH_PATH |
martinstannard/ruby-processing | samples/processing_app/3D/form/brick_tower.rb | <filename>samples/processing_app/3D/form/brick_tower.rb
require 'ruby-processing'
# Original by <NAME>
# 3D castle tower constructed out of individual bricks.
# Uses the PVecor and Cube classes.
class BrickTower < Processing::App
def setup
@bricks_per_layer = 16
@brick_layers = 18
@brick_width, @bric... |
martinstannard/ruby-processing | lib/ruby-processing/exporters/base_exporter.rb | <gh_stars>1-10
require 'fileutils'
require 'erb'
module Processing
# This base exporter implements some of the common
# code-munging needed to generate apps and applets.
class BaseExporter
include FileUtils
DEFAULT_TITLE = "Ruby-Processing Sketch"
DEFAULT_DIMENSIONS = {'width' => '500', 'hei... |
martinstannard/ruby-processing | lib/ruby-processing.rb | # Ruby-Processing is for Code Art.
# Send suggestions, ideas, and hate-mail to jashkenas [at] gmail.com
# Also, send samples and libraries.
unless defined? RP5_ROOT
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
RP5_ROOT = File.expand_path(File.dirname(__FILE__) + "/../")
end
require 'ruby-processing/help... |
zapt-tech/zapt-location-ios-sdk | ZaptLocation-iOS-SDK.podspec | <reponame>zapt-tech/zapt-location-ios-sdk
Pod::Spec.new do |s|
s.name = 'ZaptLocation-iOS-SDK'
s.version = '0.0.10-rc1'
s.summary = 'SDK for indoor positioning'
s.homepage = 'http://docs.zapt.tech/'
s.author = { "Zapt Tecnologia de Localizacao L... |
rendegosling/game_tictactoe | game_tictactoe.rb | class GameTicTacToe
def initialize
@board = Board.new
setup_players
assign_starting_player
end
def setup_players
@player_1 = Player.new("Player 1", :x, @board)
@player_2 = Player.new("Player 2", :o, @board)
end
def assign_starting_player
@current_player = @player_1
end
def pla... |
rendegosling/game_tictactoe | merged_list.rb | lists = [[1,4,5],[1,3,4],[2,6]]
merged_list = []
lists.each do |list|
merged_list += list
end
puts merged_list.sort |
voc/eventkalender | spec/lib/eventkalender/event/conference_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe Eventkalender::Conference do
before(:each) do
@event = Eventkalender::Conference.new(name: 'my todes event',
location: 'todes location',
start_date: '24.04.1999',
... |
voc/eventkalender | lib/eventkalender/event/meeting.rb | <filename>lib/eventkalender/event/meeting.rb
# frozen_string_literal: true
class Eventkalender
# Represents a voc event.
#
# @!attribute [rw] start_date
# @param date [String] witch represents start date of the event
# @return [Date] event start date
# @!attribute [rw] end_date
# @param date [Strin... |
voc/eventkalender | spec/lib/eventkalender/event/meeting_spec.rb | <gh_stars>1-10
# frozen_string_literal: true
require 'spec_helper'
describe Eventkalender::Meeting do
before(:each) do
@meeting = Eventkalender::Meeting.new(
name: '<NAME>',
type: 'Mumble',
location: 'todes location',
start_date: '24.04.1999',
end_date: '24.04.2000',
link: 'h... |
voc/eventkalender | scripts/unicorn.rb | # frozen_string_literal: true
process = ENV['PROCESS'] || 1
listen = ENV['LISTEN'] || 8000
worker_processes process
listen listen
stdout_path '/var/log/unicorn/stdout.log'
stderr_path '/var/log/unicorn/stderr.log'
|
voc/eventkalender | spec/lib/eventkalender/parser/parser_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe Eventkalender::Parser do
before(:each) do
@parser = Eventkalender::Parser.new
@scraper = Eventkalender::Scraper.new
end
after(:each) do
@parser = nil
end
# TODO: fix tests
#
# describe '#events' do
# it 'should return an ar... |
voc/eventkalender | lib/eventkalender/parser/parser.rb | # frozen_string_literal: true
# stdlib
require 'pathname'
require 'date'
require 'rss'
require 'json'
# gem
require 'icalendar'
class Eventkalender
# Parser class can be used to parse dokuwiki table and return events in multiple formats.
#
# @example Create parser to parse voc wiki events page.
# parser = E... |
voc/eventkalender | lib/eventkalender/parser/conferences.rb | <filename>lib/eventkalender/parser/conferences.rb
# frozen_string_literal: true
class Eventkalender
class Parser::Conferences < Eventkalender::Parser
def initialize(event_table)
@event_table = event_table
parse(event_table)
end
def events(events = parse)
events
end
# Converts ... |
voc/eventkalender | webapp.rb | <filename>webapp.rb
# frozen_string_literal: true
require 'sinatra'
require 'sinatra/namespace'
require 'haml'
require_relative 'lib/eventkalender'
set :views, File.dirname(__FILE__) + '/views'
set :parser, Eventkalender::Parser.new
set :public_folder, File.dirname(__FILE__) + '/views/public'
set :sub_path, ''
# ... |
voc/eventkalender | spec/lib/eventkalender/scraper_spec.rb | <gh_stars>1-10
# frozen_string_literal: true
require 'spec_helper'
describe Eventkalender::Scraper do
before(:each) do
@scraper = Eventkalender::Scraper.new
end
after(:each) do
@scraper = nil
end
describe '#new' do
# TODO: pending
end
describe '.scrape!' do
it 'should return Nokogiri:... |
voc/eventkalender | spec/webapp_spec.rb | # frozen_string_literal: true
require 'spec_helper'
describe 'Webpage eventkalender' do
# conferences
describe '/events.ical' do
it 'should return valid response on GET' do
get '/events.ical'
expect(last_response).to be_ok
end
it 'should return valid ical feed' do
get '/events.ical... |
voc/eventkalender | lib/eventkalender/event/conference.rb | <gh_stars>1-10
# frozen_string_literal: true
class Eventkalender
# Represents a voc event.
#
# @!attribute [rw] start_date
# @param date [String] witch represents start date of the event
# @return [Date] event start date
# @!attribute [rw] end_date
# @param date [String] witch represents end date o... |
voc/eventkalender | lib/eventkalender/scraper.rb | <gh_stars>1-10
# frozen_string_literal: true
require 'mechanize'
class Eventkalender
# Web crawler that can be found event table.
#
# @example Get event page.
# scraper = Eventkalender::Scraper.new
# scraper.get_page #=> #<Eventkalender::Scraper:0x0000000148c3c0 @url="http://c3voc.de/wiki/events", @xpa... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.