travis-web does not use travis-core
This commit is contained in:
parent
73c98ef9db
commit
0d062be3a0
1
Gemfile
1
Gemfile
|
@ -6,6 +6,7 @@ gem 'rack-ssl', '~> 1.3'
|
|||
gem 'rack-protection', '~> 1.3'
|
||||
gem 'rack-mobile-detect'
|
||||
gem 'sinatra'
|
||||
gem 'hashr'
|
||||
|
||||
gem 'rake-pipeline', github: 'livingsocial/rake-pipeline'
|
||||
gem 'rake-pipeline-web-filters', github: 'wycats/rake-pipeline-web-filters'
|
||||
|
|
10
Gemfile.lock
10
Gemfile.lock
|
@ -49,6 +49,11 @@ GEM
|
|||
pry (>= 0.9.10)
|
||||
terminal-table (>= 1.4.3)
|
||||
thor (>= 0.14.6)
|
||||
handlebars (0.4.0)
|
||||
commonjs (~> 0.2.3)
|
||||
therubyracer (~> 0.11.1)
|
||||
hashr (0.0.22)
|
||||
i18n (0.6.3)
|
||||
json (1.7.7)
|
||||
libv8 (3.16.14.3)
|
||||
listen (2.7.9)
|
||||
|
@ -119,7 +124,10 @@ DEPENDENCIES
|
|||
compass
|
||||
foreman
|
||||
guard
|
||||
libv8 (~> 3.16.0)
|
||||
handlebars
|
||||
hashr
|
||||
localeapp
|
||||
localeapp-handlebars_i18n
|
||||
puma
|
||||
rack-mobile-detect
|
||||
rack-protection (~> 1.3)
|
||||
|
|
|
@ -3,6 +3,11 @@ module Travis
|
|||
autoload :Allow, 'travis/web/allow'
|
||||
autoload :ApiRedirect, 'travis/web/api_redirect'
|
||||
autoload :App, 'travis/web/app'
|
||||
autoload :Config, 'travis/web/config'
|
||||
autoload :SetToken, 'travis/web/set_token'
|
||||
end
|
||||
|
||||
def self.config
|
||||
@config ||= Travis::Web::Config.new
|
||||
end
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ class Travis::Web::App
|
|||
def build(options = {})
|
||||
builder = Rack::Builder.new
|
||||
if options[:environment] == 'production'
|
||||
builder.use Rack::SSL, hsts: Travis.config.ssl.hsts || true
|
||||
builder.use Rack::SSL, hsts: Travis.config.ssl.hsts
|
||||
end
|
||||
builder.use Rack::Deflater
|
||||
builder.use Rack::Head
|
||||
|
|
50
lib/travis/web/config.rb
Normal file
50
lib/travis/web/config.rb
Normal file
|
@ -0,0 +1,50 @@
|
|||
require 'hashr'
|
||||
require 'yaml'
|
||||
|
||||
# Encapsulates the configuration necessary for travis-listener.
|
||||
#
|
||||
# Configuration values will be read from
|
||||
#
|
||||
# * either ENV['travis_config'] (this variable is set on Heroku by `travis config [env]`,
|
||||
# see travis-cli) or
|
||||
# * a local file config/travis.yml which contains the current env key (e.g. development,
|
||||
# production, test)
|
||||
#
|
||||
# The env key can be set through various ENV variables, see Travis::Config.env.
|
||||
#
|
||||
module Travis
|
||||
module Web
|
||||
class Config < Hashr
|
||||
class << self
|
||||
def env
|
||||
ENV['ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
||||
end
|
||||
|
||||
def load_env
|
||||
@load_env ||= YAML.load(ENV['travis_config']) if ENV['travis_config']
|
||||
end
|
||||
|
||||
def load_file
|
||||
@load_file ||= YAML.load_file(filename)[env] if File.exists?(filename) rescue {}
|
||||
end
|
||||
|
||||
def filename
|
||||
@filename ||= File.expand_path('config/travis.yml')
|
||||
end
|
||||
end
|
||||
|
||||
define ssl: { hsts: true }
|
||||
|
||||
default _access: [:key]
|
||||
|
||||
def initialize(data = nil, *args)
|
||||
data ||= self.class.load_env || self.class.load_file || {}
|
||||
super
|
||||
end
|
||||
|
||||
def env
|
||||
self.class.env
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user